Home/Blog/SSL Certificate Formats Explained: PEM, DER, PFX, P7B, CER, and CRT
Cybersecurity

SSL Certificate Formats Explained: PEM, DER, PFX, P7B, CER, and CRT

A comprehensive guide to understanding SSL/TLS certificate formats including PEM, DER, PFX/PKCS#12, P7B/PKCS#7, CER, and CRT—when to use each format and how to convert between them.

By Inventive HQ Team
SSL Certificate Formats Explained: PEM, DER, PFX, P7B, CER, and CRT

SSL/TLS certificates come in a bewildering array of formats and file extensions. If you've ever struggled with "invalid certificate format" errors when configuring a web server, installing a certificate on Windows IIS, or deploying to a cloud platform, you're not alone. Understanding certificate formats is essential for anyone managing web security infrastructure.

This comprehensive guide breaks down every major certificate format—PEM, DER, PFX/PKCS#12, P7B/PKCS#7, CER, and CRT—explaining their technical characteristics, use cases, platform compatibility, and how to convert between them.

Understanding Encoding vs. File Extensions

Before diving into specific formats, it's important to distinguish between encoding (how data is structured) and file extensions (what the file is named).

Encoding refers to how the certificate data is represented:

  • PEM: Base64-encoded text with header/footer lines
  • DER: Binary encoding

File extensions are just naming conventions:

  • .crt, .cer, .pem, .key typically contain PEM-encoded data
  • .der typically contains DER-encoded data
  • .pfx, .p12 contain PKCS#12 archives
  • .p7b, .p7c contain PKCS#7 structures

The confusing part: file extensions aren't always reliable indicators of the actual format inside. A .cer file might contain either PEM or DER encoding. You often need to examine the file contents to know for sure.

PEM Format (Privacy-Enhanced Mail)

PEM is the most common certificate format, especially in the Linux/Unix world. Despite the name, it has nothing to do with email anymore—the format was originally designed for secure email transmission in the 1990s but is now the de facto standard for certificate files.

Characteristics:

  • Text-based format using Base64 encoding
  • Readable in any text editor
  • Enclosed in header/footer lines like -----BEGIN CERTIFICATE-----
  • Each certificate, key, or request gets its own BEGIN/END block
  • Can contain multiple certificates in a single file (certificate chain)

Example PEM Certificate:

-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAKL0UG+mRKkzMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMQ0wCwYDVQQKDARUZXN0MRIwEAYD
VQQDDAlsb2NhbGhvc3QwHhcNMjUwMTIwMDAwMDAwWhcNMjYwMTIwMDAwMDAwWjBF
... (more base64 data) ...
-----END CERTIFICATE-----

Common Uses:

  • Apache, Nginx, and most Linux-based web servers
  • Cloud platforms (AWS, Google Cloud, Azure)
  • Let's Encrypt and other free Certificate Authorities
  • OpenSSL command-line operations
  • Docker containers and Kubernetes

File Extensions:

  • .pem - Generic PEM file
  • .crt - Certificate (PEM-encoded)
  • .cer - Certificate (PEM-encoded on Linux, DER on Windows)
  • .key - Private key (PEM-encoded)

Advantages:

  • Human-readable, easy to copy/paste
  • Works across virtually all platforms
  • Can concatenate multiple certificates for a full chain
  • Easy to verify contents visually

Disadvantages:

  • Larger file size than DER (base64 encoding adds ~33% overhead)
  • Private keys stored unencrypted by default (though can be encrypted with a passphrase)
  • Easy to accidentally share private keys (they're plain text)

DER Format (Distinguished Encoding Rules)

DER is a binary encoding of the same ASN.1 structures used in PEM. It's essentially PEM without the base64 encoding and header/footer lines—just the raw binary certificate data.

Characteristics:

  • Binary format (not human-readable)
  • Compact, efficient encoding
  • No header/footer lines
  • Single certificate per file (can't chain multiple certificates)
  • Identical data to PEM, just different encoding

Common Uses:

  • Java applications (Tomcat, JBoss)
  • Windows environments (sometimes)
  • Binary protocols where text encoding is inefficient
  • Embedded systems with limited memory

File Extensions:

  • .der - DER-encoded certificate or key
  • .cer - Certificate (DER-encoded on Windows, PEM on Linux)

Advantages:

  • Smaller file size than PEM
  • Efficient for binary protocols
  • Less overhead when parsing programmatically

Disadvantages:

  • Not human-readable (can't inspect in a text editor)
  • Harder to copy/paste
  • Less universally supported than PEM
  • Can't easily concatenate certificate chains

PFX/PKCS#12 Format (Personal Information Exchange)

PFX, also known as PKCS#12 or P12, is a binary archive format that can bundle multiple cryptographic objects into a single, password-protected file. Think of it as a "certificate suitcase" that contains everything you need.

Characteristics:

  • Binary archive format (like a ZIP file for certificates)
  • Password-protected with strong encryption
  • Can contain: certificate + private key + intermediate certificates + root CA
  • Supports multiple encryption algorithms (TripleDES, AES-256, RC2)
  • Self-contained—everything in one file

Example Contents: A typical PFX file contains:

  1. Your server certificate
  2. Your private key (encrypted)
  3. Intermediate CA certificate(s)
  4. Optionally, the root CA certificate

Common Uses:

  • Windows servers (IIS, Exchange)
  • Azure App Service
  • Importing certificates into Windows Certificate Store
  • Code signing certificates
  • S/MIME email certificates
  • iOS device profiles (requires TripleDES encryption)

File Extensions:

  • .pfx - Personal Information Exchange (Windows naming)
  • .p12 - PKCS#12 (cross-platform naming)

Advantages:

  • Everything in one convenient file
  • Strong password protection
  • Impossible to accidentally use certificate without private key
  • Easy to backup and transfer securely
  • Widely supported on Windows

Disadvantages:

  • Binary format (not human-readable)
  • Must remember the password (unrecoverable if lost)
  • Some platforms don't support it (older Linux systems)
  • Different encryption algorithms cause compatibility issues

iOS Compatibility Note: iOS devices require PFX files to use TripleDES encryption, not AES-256. When creating a PFX file for iPhone/iPad configuration profiles, you must explicitly specify TripleDES as the encryption algorithm.

P7B/PKCS#7 Format (Cryptographic Message Syntax)

P7B, also known as PKCS#7, is a container format designed to hold multiple certificates for certificate chain verification. Unlike PFX, it cannot store private keys—only certificates.

Characteristics:

  • Can be either PEM or DER encoded
  • Contains one or more certificates (typically a chain)
  • No private key support
  • Used for certificate distribution, not deployment
  • Based on S/MIME and CMS standards

Example Contents: A typical P7B file contains:

  1. Your server certificate
  2. Intermediate CA certificate(s)
  3. Optionally, the root CA certificate

Common Uses:

  • Windows Certificate Authorities
  • Java keystores (Tomcat)
  • Certificate chain distribution
  • Microsoft platforms (Windows, IIS)

File Extensions:

  • .p7b - PKCS#7 certificate bundle
  • .p7c - PKCS#7 certificate bundle

Advantages:

  • Safe to distribute (no private key)
  • Contains full certificate chain
  • Can be base64-encoded (readable) or binary
  • Widely supported on Windows

Disadvantages:

  • Can't contain private keys (need separate key file)
  • Less common on Linux/Apache/Nginx
  • Requires conversion for many use cases

CER Format (Certificate)

CER is a file extension, not a format. CER files can contain either PEM or DER encoding, making them particularly confusing. The actual encoding depends on the platform and how the file was created.

Characteristics:

  • File extension only (not a format)
  • Usually PEM-encoded on Linux/macOS
  • Usually DER-encoded on Windows
  • Contains only the certificate (not the private key)

Common Uses:

  • Windows platforms (double-click to install)
  • SSL certificate downloads from CAs
  • Certificate distribution

File Extensions:

  • .cer - Certificate (encoding varies)

Identification Tip: Open the file in a text editor. If you see -----BEGIN CERTIFICATE-----, it's PEM-encoded. If you see binary garbage, it's DER-encoded.

CRT Format (Certificate)

Like CER, CRT is primarily a file extension rather than a distinct format. CRT files are almost always PEM-encoded on Linux/Unix systems.

Characteristics:

  • File extension only
  • Almost always PEM-encoded
  • Contains only the certificate (not the private key)
  • Common on Linux/Apache/Nginx

Common Uses:

  • Linux web servers
  • SSL certificate storage
  • Certificate distribution on Unix systems

File Extensions:

  • .crt - Certificate (usually PEM-encoded)

Platform Compatibility Guide

Different platforms prefer different certificate formats:

Apache/Nginx (Linux):

  • Certificate: PEM (.crt, .pem)
  • Private Key: PEM (.key)
  • Chain: PEM (.pem) with multiple certificates

IIS (Windows):

  • Preferred: PFX/PKCS#12 (.pfx)
  • Alternative: PEM certificates + separate key (requires binding)

Java (Tomcat/JBoss):

  • Java KeyStore (.jks) created from PFX/PKCS#12
  • Alternative: P7B chain + separate DER key

Cloud Platforms:

  • AWS: PEM format
  • Google Cloud: PEM format
  • Azure: PFX/PKCS#12 or PEM

Code Signing:

  • Windows: PFX/PKCS#12 (.pfx)
  • Java: JKS created from PFX

iOS Configuration:

  • PFX/PKCS#12 with TripleDES encryption

Converting Between Formats

Converting certificate formats is a common task. Here's what you need for each conversion:

PEM to DER: Input: PEM certificate Output: DER binary certificate Use case: Java applications

DER to PEM: Input: DER binary certificate Output: PEM text certificate Use case: Moving from Windows to Linux

PEM to PFX: Input: PEM certificate + PEM private key (+ optional chain) Output: PFX archive (password-protected) Use case: Deploying to Windows IIS or creating iOS profiles

PFX to PEM: Input: PFX archive (with password) Output: Separate PEM certificate and PEM private key files Use case: Moving from Windows to Linux

PEM to P7B: Input: One or more PEM certificates Output: P7B certificate bundle Use case: Certificate chain distribution

P7B to PEM: Input: P7B certificate bundle Output: Separate PEM certificate files Use case: Extracting certificates for Linux servers

Security Considerations

When handling certificate files, security is paramount:

Private Key Protection:

  • PEM keys are unencrypted by default—encrypt with a passphrase
  • PFX/PKCS#12 files are always password-protected
  • Never store unencrypted private keys in version control
  • Use strong passwords (20+ characters) for PFX files

File Permissions: On Linux, private keys should have restrictive permissions:

chmod 600 private.key  # Read/write for owner only

Secure Transfer:

  • Never email private keys (even in PFX format)
  • Use secure file transfer (SFTP, SCP)
  • Consider encrypting with PGP/GPG before transfer

Backup Strategy:

  • Store encrypted backups of PFX files offline
  • Keep passwords in a separate, secure location
  • Test restoration procedures regularly

Conclusion

Understanding SSL/TLS certificate formats—PEM, DER, PFX/PKCS#12, P7B/PKCS#7, CER, and CRT—is essential for anyone managing web security infrastructure. While the variety of formats can be confusing, each serves specific purposes and platforms.

Quick Recommendations:

  • Linux/Apache/Nginx: Use PEM format (.crt and .key files)
  • Windows/IIS: Use PFX/PKCS#12 format (.pfx file)
  • iOS Profiles: Use PFX with TripleDES encryption
  • Certificate Chains: Use PEM (multiple certificates) or P7B
  • Cross-Platform: Convert to the format your platform expects

Need to convert certificate formats or generate a new CSR? Try our Certificate CSR Generator & Format Converter tool—it handles all major formats with 100% client-side processing for maximum security.

Need Expert Cybersecurity Guidance?

Our team of security experts is ready to help protect your business from evolving threats.