Reference guide · dns-ssl · Published 2026-08-15 · 3 min read

SSL certificate formats and conversion

How PEM, DER, PKCS12 and PFX certificates differ and how to convert between formats with OpenSSL.

A TLS certificate is data, and how that data is encoded on disk changes whether a server can read it. The same certificate can exist as PEM, DER or PKCS12, and failing to match the format a server expects is one of the most common causes of "certificate file not found" and password-prompt errors despite the certificate being valid. Knowing the formats and the OpenSSL commands to convert them resolves those quickly.

Formats compared

Conversion basics

All conversion runs through OpenSSL. To read what is inside an unknown file first, without changing it:

openssl x509 -in cert.crt -text

To convert PEM containing both key and certificate into a PKCS12:

openssl pkcs12 -export -out combined.pfx -inkey key.pem -in cert.pem -certfile chain.pem

To extract the certificate and key from a PKCS12 back to PEM:

openssl pkcs12 -in combined.pfx -out key+chain.pem -nodes

The -nodes flag leaves the key unencrypted, which is what a web server like Nginx needs when reading the key directly. To get DER from PEM, or PEM from DER:

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

Which to use

PEM with the key stored separately is the normal choice for web servers on Linux. Reach for PKCS12 only when the target tool explicitly expects it, most commonly Windows or an appliance that imports the private key through a browser or administrator console. DER appears when an old tool or an intermediate step needs the bare binary certificate. The private key never changes format semantics across these; PEM and PKCS12 differ mainly in whether the key travels inside the same file and how it is encrypted.

Chain and key hygiene

When converting, check that the file you produce includes any intermediate certificates, because a server with a PEM file that holds only the leaf certificate fails the handshake for every client that lacks the trusted intermediate. An incomplete chain is the silent failure that survives a format conversion. Take a sanity check after converting by hosting the file on the server and reading it back, or by running a server config test such as nginx -t, which reports an unreadable key or certificate immediately.

Retiring and reusing a certificate between hosts is where format mismatches bite hardest. Compare this with the renewal checklist to see the steps that keep a fresh key and chain consistent across every server that needs them.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services