Tools: Latest: Convert PEM to PFX (PKCS#12) with OpenSSL

Tools: Latest: Convert PEM to PFX (PKCS#12) with OpenSSL

Convert PEM to PFX (PKCS#12) with OpenSSL

Basic conversion

Including a CA chain

Scripting (non-interactive)

Skip the conversion entirely

Reverse: PFX to PEM

Modern vs legacy PKCS#12

Troubleshooting

"Error unable to get local issuer certificate"

"Mac verify error"

The PFX imports but is "not associated with a private key"

Further Reading Bundle your cert and key into a single password-protected PFX file — the format Windows, IIS, and Java expect. PEM (two files: .crt + .key) is the native format on Linux and most open-source servers. PFX (also called PKCS#12, .pfx, or .p12) bundles both into a single password-protected file — required by IIS, Windows Certificate Store, and Java keystores. OpenSSL will prompt for a password. Enter something non-empty — Windows refuses to import PFX files with empty passwords. If your cert has a chain (intermediate CA certs), include them with -certfile: To avoid the password prompt, pass it via -passout: Security warning: Using pass: puts the password in your shell history and process list. Prefer file:/path/to/passwordfile or env:VARNAME. Our generator can output PFX directly. Pick "PFX" as the output format, enter a password, and get a ready-to-import file. Extract the certificate: Extract the private key (unencrypted — dev only): Extract the CA chain only: OpenSSL 3+ uses modern PKCS#12 encryption (AES-256) by default, which some older Windows versions can't read. If IIS or a legacy Windows tool refuses to import your PFX, regenerate with legacy encryption: Your cert is signed by a chain your OpenSSL can't resolve. Use -certfile to supply the chain, or use -CAfile /etc/ssl/certs/ca-certificates.crt. Wrong password when decrypting a PFX. If you don't know the password, there's no recovery — you'll need the original PEM files. The private key didn't match the certificate's public key. Check with our PEM decoder — if the public key differs from what your key computes, they're not a matching pair. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -certfile ca-chain.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -certfile ca-chain.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -certfile ca-chain.pem \ -name "My Certificate" openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -password pass:MyPassword123 openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -password pass:MyPassword123 openssl pkcs12 -export \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem \ -password pass:MyPassword123 openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private-key.pem openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private-key.pem openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private-key.pem openssl pkcs12 -in certificate.pfx -cacerts -nokeys -out ca-chain.pem openssl pkcs12 -in certificate.pfx -cacerts -nokeys -out ca-chain.pem openssl pkcs12 -in certificate.pfx -cacerts -nokeys -out ca-chain.pem openssl pkcs12 -export -legacy \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem openssl pkcs12 -export -legacy \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem openssl pkcs12 -export -legacy \ -out certificate.pfx \ -inkey private-key.pem \ -in certificate.pem - Nginx setup (uses PEM) - Trust on Windows (often uses PFX)