Convert PFX to PEM
A .pfx (also .p12) file is a PKCS#12 container that bundles a certificate, its private key and often the intermediate chain, protected by a password. Apache, Nginx and most Linux tools want PEM files instead. OpenSSL splits the container for you.
File formats at a glance
| Format | Extensions | Contents | Typical use |
|---|---|---|---|
| PKCS#12 | .pfx, .p12 | Certificate, key, chain, password protected | Windows, IIS, Java |
| PEM | .pem, .crt, .key | Base64 text, one or more items | Apache, Nginx, Linux |
| DER | .der, .cer | Binary certificate | Java, some devices |
Extract everything in one file
openssl pkcs12 -in example.pfx -out all.pem -nodes
Enter the import password when asked. The -nodes flag leaves the key unencrypted, so protect the output file. Open all.pem in a text editor and split the blocks if you need separate files.
PFX to PEM: extract each part
# Certificate only
openssl pkcs12 -in example.pfx -clcerts -nokeys -out certificate.pem
# Private key only (unencrypted)
openssl pkcs12 -in example.pfx -nocerts -nodes -out private.key
# CA chain only
openssl pkcs12 -in example.pfx -cacerts -nokeys -chain -out chain.pem
The certificate output may begin with "Bag Attributes" lines. Remove everything outside the BEGIN and END lines if your server complains.
Check the result
- Confirm the key matches the certificate with the Key Matcher.
- Read the certificate details with the SSL Decoder.
- Install the files, reload the server and run the SSL Checker.
If you do not want to use a terminal, the SSL Converter handles the same conversions. Avoid uploading a private key to tools you do not trust. Running OpenSSL locally keeps it on your machine.
PFX to PEM: common errors
- Mac verify error: invalid password? The import password is wrong. Check for typos or ask whoever created the file.
- Unsupported algorithm or "unsupported" in OpenSSL 3: the file uses an old encryption method. Add
-legacyto the command, which requires the legacy provider to be available. - Empty key file: the PFX may hold only the certificate. You need the original key.
Going the other way
To build a PFX from PEM files, use openssl pkcs12 -export. Our guide on installing SSL on IIS shows the full command.
Related reading: converting CRT to PEM, converting PEM to a Java keystore, installing a PFX on Windows hosting and Fix Certificate Verify Failed.
Frequently Asked Questions
Is a .p12 file the same as .pfx?
Yes. Both are PKCS#12. The extension differs by platform.
Should I keep the PFX password?
Store it in a password manager. Without it, the file cannot be opened.
Can I get a free certificate in PEM directly?
TryFreeSSL provides PEM files, so you only need PFX conversion for Windows targets.
Is it safe to leave the key unencrypted?
On a server, key files are normally unencrypted but must be readable only by the service account. Set permissions such as chmod 600.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.