Back to Articles
Guide2026-07-08•5 min read•CSR.plus Team

SSL Certificate Formats: PEM vs DER vs PFX vs P7B vs PKCS#8

SSL Certificate Formats: PEM vs DER vs PFX vs P7B vs PKCS#8

SSL Certificate Formats Explained: PEM vs DER vs PKCS#12/PFX vs PKCS#7/P7B vs PKCS#8

Direct answer: certificate formats differ on only two axes — how they are encoded (Base64 text vs binary) and what they contain (certificate only / chain / chain + private key). PEM is Base64 text wrapped in -----BEGIN----- armor (RFC 7468), the default on Nginx and Apache. DER is the same content in binary ASN.1. PFX (PKCS#12, RFC 7292) bundles the private key and chain into one password-protected file, used by IIS and Windows. P7B (PKCS#7, RFC 2315 → RFC 5652) carries the chain only, never the private key. PKCS#8 (RFC 5958) is the algorithm-agnostic container for a private key. Fastest check: open the file — visible -----BEGIN means PEM, binary garbage means DER or PKCS#12.

Comparison table

FormatExtensionsEncodingPrivate key?Typical useSpec
PEM.pem .crt .cer .keyBase64 textDepends on contentNginx, Apache, LinuxRFC 7468
DER.der .cerBinary ASN.1No (cert only)Java, Windows import—
PKCS#12 / PFX.pfx .p12BinaryYesIIS, Windows, TomcatRFC 7292
PKCS#7 / P7B.p7b .p7cBase64 or binaryNoImporting the intermediate chainRFC 2315 → RFC 5652
PKCS#8.key .pemBase64 or DERYes (key only)OpenSSL 3.x, modern serversRFC 5958

Core concepts

PEM (RFC 7468)

Base64 with armor lines. Multiple blocks can be concatenated (leaf first, then intermediates). The header tells you what is inside: CERTIFICATE, PRIVATE KEY (PKCS#8), RSA PRIVATE KEY (PKCS#1), EC PRIVATE KEY (SEC1), ENCRYPTED PRIVATE KEY, CERTIFICATE REQUEST.

DER

The raw binary encoding, no armor. Required by some Java and Windows import paths. PEM and DER convert losslessly; they are not "two different certificates".

PKCS#12 / PFX (RFC 7292)

A password-protected container holding the private key, leaf and chain. It is the de facto format for Windows/IIS. Because it contains a private key, always use a strong export password and never leave it in a public directory.

PKCS#7 / P7B (RFC 2315 → RFC 5652)

Chain only, commonly used to import intermediates into Windows or a Java trust store. It never contains the private key, so you must still have the original key.

PKCS#8 vs PKCS#1 vs SEC1 (RFC 5958)

These describe private key storage only. PKCS#8 is algorithm-agnostic (PRIVATE KEY), PKCS#1 is RSA-specific (RSA PRIVATE KEY), SEC1 is EC-specific (EC PRIVATE KEY). Normalising on PKCS#8 avoids most cross-language issues.

How to identify, convert and verify in 7 steps

Step 1 — Identify what you actually have (never trust the extension)

file cert.crt        # "ASCII text" vs "data"
head -n 1 cert.crt   # -----BEGIN means PEM

Step 2 — Inspect it (Certificate Decoder does this locally in your browser)

openssl x509 -in cert.pem -noout -text

Step 3 — PEM ↔ DER

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

Step 4 — PEM ↔ P7B (chain)

openssl crl2pkcs7 -nocrl -certfile cert.pem -certfile chain.pem -out bundle.p7b
openssl pkcs7 -print_certs -in bundle.p7b -out bundle.pem

Step 5 — PEM + key ↔ PFX

openssl pkcs12 -export -out bundle.p12 -inkey key.pem -in cert.pem -certfile chain.pem
openssl pkcs12 -in bundle.p12 -out bundle.pem     # OpenSSL 3.x: add -noenc for an unencrypted key

Two OpenSSL 3.x gotchas: the old -nodes flag is now -noenc, and legacy PFX files encrypted with RC2/3DES may need -legacy. Exports use AES-256-CBC with PBKDF2 by default.

Step 6 — Normalise the private key to PKCS#8

openssl pkcs8 -topk8 -nocrypt -in key-rsa.pem -out key8.pem

Step 7 — Verify after deployment (or use SSL Checker)

openssl s_client -connect example.com:443 -servername example.com

Troubleshooting checklist

SymptomCauseFix
unable to load certificateFile is actually DER or P7BAdd -inform DER, or convert to PEM first
Expecting: TRUSTED CERTIFICATEDamaged armor lines / stray blank linesRegenerate the PEM; keep header and footer on their own lines
Nginx key values mismatchCertificate and key are not a pairSee the key-matching guide or use Certificate & Key Matcher
IIS rejects the PFX passwordExported by a third-party tool with incompatible cryptoRe-export with openssl pkcs12 -export
Java Invalid keystore formatPEM handed to a JKS storeConvert to PKCS#12 first, then keytool -importkeystore
Key header says ENCRYPTED PRIVATE KEYService cannot start unattendedopenssl pkey -in key.pem -out key-plain.pem
Certificate broken after email copyLine wrapping, BOM or CRLF damageRe-download; never copy from an email body
Certificate now expires in 200 daysCA/B Forum SC-081v3 is in forceFold format checks into your renewal automation

Further reading

Tools: Certificate Decoder · Format Converter · Certificate & Key Matcher

Related: Check Whether a Certificate Matches Its Private Key · Fixing an Incomplete Certificate Chain · ACME HTTP-01 vs DNS-01

Go deeper: SSL Certificates: The Complete Guide · Certificate Types Compared

FAQ

Can .crt, .cer and .key extensions tell me the format?

No. Extensions are conventions only — a .cer can be PEM or DER. Inspect the content or use file.

Do servers require a PKCS#8 private key?

Not strictly, but PKCS#8 is algorithm-agnostic and travels cleanly between OpenSSL 3.x, Go and Java. Convert back to PKCS#1 only if a legacy system demands it.

Can I remove the password from a PFX?

Yes, but only when operationally necessary, and then lock down file permissions. On OpenSSL 3.x use -noenc.

Does the move to 200-day certificates change any format?

No format changes — only frequency. Build "identify → match check → chain check" into every renewal.

What does Nginx need?

PEM: ssl_certificate = fullchain (leaf + intermediates), ssl_certificate_key = private key.

Free SSL/TLS tools

Verify and inspect your certificates in seconds.

Related Certificate Info

Learn more about choosing and buying certificates.