Format:PEM
| On this wiki | Facts · Code · Notes · Topics |
|---|
Base64-armored text container for DER objects (certificates, keys, CSRs) with -----BEGIN label----- lines; the label tells what the DER inside is.
Armor
A PEM block is a line -----BEGIN <label>-----, optional header lines (for example the legacy Proc-Type/DEK-Info encryption headers, Unverified: not read in this pass), base64 of the DER body, and -----END <label>-----. Searching a binary for the ASCII string -----BEGIN finds embedded keys and certificates; the label decides the content.
Labels defined by OpenSSL
From include/openssl/pem.h (see Fact:PEM/string/OpenSSL PEM labels): CERTIFICATE (PEM_STRING_X509), X509 CERTIFICATE (old), TRUSTED CERTIFICATE, CERTIFICATE REQUEST (and old NEW CERTIFICATE REQUEST), X509 CRL, PRIVATE KEY (unencrypted PKCS#8), ENCRYPTED PRIVATE KEY (encrypted PKCS#8), PUBLIC KEY (SubjectPublicKeyInfo), RSA PRIVATE KEY (PKCS#1), RSA PUBLIC KEY, DSA PRIVATE KEY, DSA PARAMETERS, EC PRIVATE KEY (SEC1), EC PARAMETERS, DH PARAMETERS, X9.42 DH PARAMETERS, PKCS7, PKCS #7 SIGNED DATA, CMS, SM2 PRIVATE KEY, ATTRIBUTE CERTIFICATE, ECHCONFIG, ANY PRIVATE KEY, PARAMETERS, SSL SESSION PARAMETERS.
Not an OpenSSL label: OPENSSH PRIVATE KEY is written by OpenSSH with its own markers, see Format:OpenSSH private key. PGP armor is a different scheme, see Format:OpenPGP.
The base64 body of a CERTIFICATE starts with MII because the DER starts with 30 82. Unverified: this follows from the base64 alphabet (0x30 0x82 gives MI), the third character depends on the length.
Related
Format:ASN.1 DER and BER, Technique:Recognizing embedded keys and certificates.
Code & repositories
- https://github.com/openssl/openssl @
cfb89e50a06a00917bdfa6142665ffee08ca79bd· license: Apache-2.0
OpenSSL: include/openssl/pem.h PEM labels and crypto/objects/objects.txt OID tree.
Tested on: source read, not run: source reading only · checked 2026-10-19; last activity 2026-10-19