ssl-guides 2026-12-02 ⏱ 3 min read

Convert PEM to PFX (PKCS#12) with OpenSSL

Convert PEM to PFX (PKCS#12) with OpenSSL
Quick Answer: Run openssl pkcs12 -export -out certificate.pfx -inkey private.key -in certificate.crt -certfile ca-bundle.crt and enter an export password. The result is a single PFX (PKCS#12) file containing the private key, certificate and chain, ready for IIS, Windows or Azure.

PEM vs PFX

FormatContentsTypical use
PEM (.pem, .crt, .key)Base64 text, usually one item per fileNginx, Apache, most Linux tools
PFX / P12 (.pfx, .p12)Binary bundle with key, certificate and chain, password protectedIIS, Windows, Azure, Java keystores

What you need

  • The private key, for example private.key
  • The server certificate, for example certificate.crt
  • The intermediate certificates, for example ca-bundle.crt (recommended, so the chain is complete)

Before converting, confirm the key and certificate belong together using the key matcher. The SSL converter can also do format changes in the browser, but avoid uploading production private keys to any website. Run OpenSSL locally instead.

Convert PEM to PFX with OpenSSL

openssl pkcs12 -export \
  -out certificate.pfx \
  -inkey private.key \
  -in certificate.crt \
  -certfile ca-bundle.crt

OpenSSL asks for an export password. Choose a strong one and store it in a password manager, because the import step will ask for it. If your files are in one fullchain file, pass that as -in and leave out -certfile.

Check the result

openssl pkcs12 -info -in certificate.pfx -noout

This prompts for the password and prints the structure without dumping the key. A MAC verified message and the expected number of certificates means the file is good. OpenSSL 3 may need -legacy when reading very old PFX files created with outdated algorithms.

Convert PFX back to PEM

# Private key
openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private.key
# Certificates (leaf and chain)
openssl pkcs12 -in certificate.pfx -nokeys -out certificate.pem

The -nodes option writes the key unencrypted, so set file permissions tightly (chmod 600) and delete copies you do not need.

Import on Windows and IIS

  1. Open IIS Manager, select the server, then Server Certificates.
  2. Click Import, choose the PFX and enter the password.
  3. Bind it to the site: Bindings, then HTTPS, then pick the certificate.

Afterwards confirm the chain and expiry with the SSL checker.

PEM to PFX: common errors

ErrorCause
"No certificate matches private key"Wrong key or certificate, check them with the key matcher
Chain incomplete on clientsIntermediates not included, add -certfile
Import asks for password you do not rememberRecreate the PFX with a new password
"Unsupported" on old WindowsLegacy algorithm requirements, test on the target system

If you still need to generate a key and request a certificate, start with our private key and CSR guide.

Import the PFX into a Java keystore

Java tools want a keystore rather than a PFX. Import it with keytool -importkeystore -srckeystore certificate.pfx -srcstoretype PKCS12 -destkeystore keystore.p12 -deststoretype PKCS12, which keeps the key and the chain in one file. Current Java versions treat PKCS12 as the default keystore type, so ask for JKS only when an older tool forces it. The PEM to Java keystore guide covers the JKS case and the alias step.

Related reading: installing free SSL on IIS and installing a certificate on Tomcat.

Frequently Asked Questions

Is PFX the same as P12?

Yes. Both are PKCS#12 files, and the extension is just a naming difference.

Does a PFX include the private key?

Yes, which is why it is password protected. Handle it like a private key.

Can I convert a certificate without the key?

Not to PFX. Without the key you can only make certificate-only formats such as CER or P7B.

Which password should I use?

Any strong one you will not lose. It only protects the file, and is not part of the certificate.

Why does OpenSSL 3 refuse my old PFX file?

The file uses legacy algorithms. Add -legacy when reading it, then export it again with current defaults.

🔄 Convert PEM Certificate to Windows .PFX Online
Convert PEM → PFX →

✅ 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 www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant