SSL certificates

Convert SSL certificate formats: PEM, CRT, DER, PFX and P7B with OpenSSL

What the common SSL certificate file formats are, how to tell them apart, and the exact OpenSSL commands to convert between PEM, DER, PFX/PKCS#12 and P7B for cPanel, Windows and other servers.

IntermediateEveryone3 min read

Certificate authorities, Windows servers and control panels do not all use the same file type. To move a certificate from IIS to cPanel, or from a CA download to a Windows server, you need to convert SSL certificate formats. OpenSSL does all of it with one command per conversion.

Before you start

  • OpenSSL installed: it is built into Linux and macOS, and included with Git for Windows. On MdmHost hosting you can run it in cPanel → Advanced → Terminal if Terminal is enabled for your account.
  • The certificate, its private key and the CA bundle (intermediate certificates).

SSL certificate formats explained

FormatExtensionsEncodingContainsUsed by
PEM.pem, .crt, .cer, .keyBase64 text with -----BEGIN linesCertificate, key or chaincPanel, Apache, Nginx, LiteSpeed
DER.der, .cerBinaryOne certificateJava, some appliances
PKCS#12.pfx, .p12Binary, password protectedCertificate, key and chain togetherWindows IIS, Exchange
PKCS#7.p7b, .p7cBase64 or binaryCertificates and chain, no keyWindows, Java Tomcat

How to identify a certificate file

Open it in a text editor. If you see -----BEGIN CERTIFICATE----- it is PEM. Unreadable binary is DER or PFX. You can also inspect it:

openssl x509 -in certificate.crt -text -noout

Convert PFX to PEM (for cPanel)

Extract the certificate and chain, then the private key:

openssl pkcs12 -in site.pfx -clcerts -nokeys -out certificate.crt
openssl pkcs12 -in site.pfx -cacerts -nokeys -out ca-bundle.crt
openssl pkcs12 -in site.pfx -nocerts -nodes -out private.key

You will be asked for the PFX password. With OpenSSL 3 and an old PFX file, add -legacy if you get an unsupported algorithm error.

Convert PEM to PFX (for Windows)

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

Choose a strong export password; you need it when importing into Windows.

Convert DER and PEM

openssl x509 -inform der -in certificate.der -out certificate.pem
openssl x509 -outform der -in certificate.pem -out certificate.der

Convert P7B to PEM

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.pem

The output contains the server certificate and the intermediates; split them into the certificate and CA bundle fields.

Check that the key matches the certificate

Both commands must print the same hash:

openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in private.key | openssl md5

For ECDSA keys, compare the public keys instead with openssl pkey -pubout and openssl x509 -pubkey -noout.

Install the converted files in cPanel

  1. Go to cPanel → Security → SSL/TLS → Manage SSL sites.
  2. Paste the certificate (CRT), private key (KEY) and CA bundle into their boxes.
  3. Click Install Certificate.

Important: A private key extracted with -nodes is unencrypted. Never email it or leave it in a public folder; delete local copies once installed.

Troubleshooting

  • Mac verify error: invalid password: wrong PFX password, or an older file that needs -legacy.
  • Key does not match certificate: the key belongs to a different CSR. Find the matching key or reissue the certificate.
  • Chain incomplete after install: the CA bundle was missing. Add the intermediates.

Frequently asked questions

Are .crt and .pem different?

Usually not. Both are often PEM text; the extension is just a naming habit.

Does converting change the certificate?

No. Only the container and encoding change. The certificate and key stay identical.

Can I convert a certificate without its private key into PFX?

No. A PFX for a server needs the private key that matches the certificate.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.