Skip to main content
Version: 1.2.0

PEM

Privacy Enhanced Mail (PEM) is a Base64-encoded format for storing cryptographic keys, certificates, and other security-related data. Despite its name, PEM is widely used beyond email applications for various cryptographic purposes.

Structure Format

ComponentDescriptionExample
Begin MarkerHeader identifying content type-----BEGIN CERTIFICATE-----
HeadersOptional key-value metadata pairsProc-Type: 4,ENCRYPTED
Encoded DataBase64-encoded binary contentMIIHzTCCBbWgAwIBAgIQaBYE3/M08XHYCnNVmcFBcjANBgkqhkiG9w0BAQsFADBy...
End MarkerFooter matching the begin marker-----END CERTIFICATE-----

Common PEM Types

TypeBegin/End LabelDescriptionUse Case
CertificateCERTIFICATEX.509 public key certificateSSL/TLS, code signing
Private KeyPRIVATE KEYPKCS#8 private keyGeneral-purpose private key storage
RSA Private KeyRSA PRIVATE KEYPKCS#1 RSA private keyRSA-specific private keys
Public KeyPUBLIC KEYX.509 SubjectPublicKeyInfoPublic key distribution
Certificate RequestCERTIFICATE REQUESTPKCS#10 certificate signing requestCertificate authority requests
DH ParametersDH PARAMETERSDiffie-Hellman parametersKey exchange configuration
EC Private KeyEC PRIVATE KEYElliptic Curve private keyEC cryptography

Encrypted PEM Format

FieldDescriptionExample
Proc-TypeProcessing type and encryption flagProc-Type: 4,ENCRYPTED
DEK-InfoEncryption algorithm and IVDEK-Info: AES-256-CBC,A1B2C3D4E5F6...
Encrypted DataBase64-encoded encrypted contentEncrypted binary data...

Example Structure

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,A1B2C3D4E5F67890A1B2C3D4E5F67890

MIIEpAIBAAKCAQEA2Z3QX0KZVE9I+sLlmEUKkYgJiEQSvfNF6JUVNBQdHPvs
kNkRFWGLQQEjLXPOCjGhvQZZLvbPjVZGKlnTJ1yJQvzjhvnP0zJhExFmKWz8
...
-----END RSA PRIVATE KEY-----

PEM files are text-based, human-readable, and can contain multiple objects separated by blank lines. They're commonly used in web servers, email systems, and various security applications.