PFX to PEM
Drop a PFX or P12 file, type its password and get the certificate, chain and private key as PEM. Nothing leaves your browser.
Also: All formats, PEM to PFX, CRT to PEM, P7B to PEM
- 0
- Certificates
- 0
- Keys
- 0
- Errors
On this page
Quick answer
Drop the .pfx file above and type its password. Then download Full chain and Key.
openssl pkcs12 -in cert.pfx -nodes -out all.pemAbout PFX to PEM
Updated
What does a PFX to PEM converter do?
A PFX file (also .p12, PKCS #12) holds a certificate, its chain and its private key in one binary file, locked with a password. Windows, IIS and Azure use it. nginx, Apache, HAProxy and Node.js want PEM: text files, one for the certificates and one for the key. This page opens the PFX and gives you each part as its own PEM file.
The PFX and its password stay in your browser. Most PFX to PEM sites upload both to a server. Here, nothing goes out: check the Network tab (F12) while you convert.
How to use this tool
- Drop the .pfx or .p12 file, or paste a PFX as Base64 (as Azure Key Vault and Kubernetes secrets store it).
- The private key is inside the PFX, so this page has no Private key tab. The Key view shows it when the password opens the file.
- You can add several files. Pick them all at once in File, or drop them together. A file you add later goes below the text that is there: it does not replace it. Clear empties the editor.
- Pick the format in To. For a PFX, type the password in the Password field. On a wide screen, To and Password are next to Convert. On a smaller screen, they are under Options, and on a phone under More.
- Copy the text, or press Download to save the file. A PFX or DER file downloads as a real binary file, ready to import.
Which file goes where
- Full chain (fullchain.pem): your certificate and the CA certificates. nginx
ssl_certificate, HAProxy, Apache 2.4.8 and newer. - Certificate (cert.pem): your certificate alone.
- Chain (chain.pem): the CA certificates, the CA bundle. Apache before 2.4.8 (
SSLCertificateChainFile). - Key (privkey.pem): the private key, not encrypted. nginx
ssl_certificate_key. - All (all.pem): every certificate, then the key, in one file. HAProxy and some load balancers.
ssl_certificate /etc/ssl/fullchain.pem;
ssl_certificate_key /etc/ssl/privkey.pem;The same tool, set up for other jobs: SSL Converter (all formats), PEM to PFX, CRT to PEM, P7B to PEM.
Common PFX to PEM errors
The wrong password, or a PFX that needs one
A PFX file is locked with a password. Without the right one, nothing inside can be read. The tool says This PFX needs its password or The password does not open this PFX, and keeps the file in the editor. Press Type the password on the error card, or type it in the Password field. A PFX from Windows with no password often has an empty one: leave the field empty.
A PFX that uses too many rounds
A PFX says how many times the password goes through the hash. These are the rounds. OpenSSL uses 2,048 by default. Each round makes the file slower to open. .NET, which many Windows programs use, refuses a PFX when its rounds add up to more than 600,000 (KB5025823). This page stops when one part of the file uses more than 600,000, and says how many rounds the file uses. Make the file again with a normal count:
openssl pkcs12 -in cert.pfx -nodes -out all.pem
openssl pkcs12 -export -in all.pem -out new.pfx -iter 2048Delete all.pem when you are done: it holds the key without a password. For an encrypted key with too many rounds, run openssl pkcs8 -topk8 -in key.pem -out new.key -iter 2048.
The key does not belong to the certificate
A PFX must hold the private key of its certificate. A key from an old CSR, or from another server, does not work with the certificate, and the server cannot use the PFX. The tool compares the public part of the key with the certificate. When they differ, it stops and shows which key and which certificate:
-----BEGIN CERTIFICATE-----
(shop.example.com, made from CSR 1)
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
(the key of CSR 2)
-----END PRIVATE KEY-----Find the key you made with the CSR for this certificate. On the server, it is often in the same folder as the old certificate. With openssl, the two lines below print the same hash when the key fits:
openssl x509 -in cert.pem -noout -pubkey | openssl sha256
openssl pkey -in privkey.pem -pubout | openssl sha256Convert PFX to PEM with openssl
The same conversion as an openssl command. Run them where the files are, on your own computer.
openssl pkcs12 -in cert.pfx -nokeys -out fullchain.pem
openssl pkcs12 -in cert.pfx -nocerts -nodes -out privkey.pemopenssl pkcs12 -in cert.pfx -nodes -out all.pemThe -nodes option writes the key without a password. It works in OpenSSL 1.1.1, OpenSSL 3 and LibreSSL. OpenSSL 3 also has the new name -noenc, which older versions do not know.
On OpenSSL 3, an old PFX made with 40-bit RC2 fails with unsupported and RC2-40-CBC. Add -legacy to the command. A PFX made with 3DES opens without it. This tool opens both without a flag.
PFX, PEM and other certificate formats
| Format | Extensions | What is inside | Used by |
|---|---|---|---|
| PEM | .pem .crt .cer .key | Base64 text between BEGIN and END lines. Certificates, chain and key, in one file or several. | nginx, Apache, HAProxy, Node.js, Linux, Let's Encrypt |
| DER | .der .cer .crt | One certificate in binary. The same data as PEM, without the Base64. | Java, Windows, Android, some routers |
| P7B | .p7b .p7c | PKCS #7: a list of certificates, often the whole chain. Never a private key. | Windows, Tomcat, Java keytool, many CAs |
| PFX | .pfx .p12 | PKCS #12: certificates and the private key in one binary file, locked with a password. | IIS, Windows, Azure, Exchange, macOS Keychain |
To read the fields of a certificate, such as the names and dates, use the Certificate Decoder.
Other certificate resources
- RFC 7292: PKCS #12The PFX format: safe bags, the key bag, password-based encryption and the MAC.
- RFC 9579: PBMAC1 in PKCS #12The newer MAC for PFX files, based on PBKDF2. OpenSSL 3.4 can make it, and this tool reads it.
- RFC 2315: PKCS #7The SignedData structure that a P7B file uses to carry a list of certificates.
- RFC 7468: Textual Encodings (PEM)The BEGIN and END lines and the labels: CERTIFICATE, PRIVATE KEY, PKCS7.
- openssl pkcs12 manualThe command that makes and opens PFX files, with -legacy, -nodes, -noenc and -certpbe.
- openssl pkcs7 manualThe command that prints the certificates in a P7B file with -print_certs.
- Can't import an AES256-SHA256 PFX (Microsoft)Which Windows versions cannot import a PFX made with AES-256, and that 3DES works there.
- KB5025823: .NET and PFX rounds (Microsoft)Why .NET refuses a PFX with more than 600,000 password rounds.
- Import-PfxCertificate (Microsoft)How Windows imports a PFX into a certificate store from PowerShell.
- node-forgeThe JavaScript library this tool uses to open and seal PFX files and encrypted keys.
PFX to PEM FAQ
How do I convert a PFX file to PEM?
Drop the .pfx or .p12 file on the editor and type its password in the Password field. The Result shows the PEM files: Full chain, Certificate, Chain, Key and All. Press Download on each one you need.
How do I extract the private key from a PFX file?
Open the PFX here and click the Key view. It shows the key as PKCS #8 PEM (BEGIN PRIVATE KEY), not encrypted. Download saves it as privkey.pem. With openssl, run openssl pkcs12 -in cert.. Keep the key file secret and delete copies you do not need.
How do I convert PFX to CRT and KEY files for nginx or Apache?
Download Full chain as fullchain.pem and Key as privkey.pem. In nginx, set ssl_certificate to the full chain and ssl_certificate_key to the key. Apache 2.4.8 and newer take the full chain in SSLCertificateFile. A file named .crt is fine: PEM and CRT are the same text.
How do I convert PFX to PEM on Windows or a Mac?
This page works on both: it runs in the browser, so you need nothing else. With openssl, run openssl pkcs12 -in cert.. The -nodes option works in OpenSSL 1.1.1, OpenSSL 3 and LibreSSL. Its new name -noenc works only in OpenSSL 3 and newer. On Windows, Git for Windows comes with openssl. On a Mac, the openssl that comes with macOS is LibreSSL. If it cannot open your PFX, use this page, or install OpenSSL 3 with Homebrew.
Why does openssl say unsupported when I open a PFX?
The PFX uses 40-bit RC2, an old cipher that OpenSSL 3 does not load by default. The error mentions RC2-40-CBC or unsupported. Add -legacy to the openssl command. A PFX made with 3DES opens without it. This tool opens both without a flag.
Is it safe to open a PFX file online?
Yes. The tool converts in your browser, in JavaScript on this page. Your files, your private key and the password are never uploaded, stored or logged, and nothing goes in the URL. The password is not saved, not even in your browser. You can check this yourself. Open the developer tools (F12), go to the Network tab and convert a file: no request goes out. Or load the page, turn off Wi-Fi and convert a PFX. For a key that guards a large site, the safest place is still your own computer: the openssl commands are on this page.