liveBook · Manning

PEM format

As explained in Software Security for Developers

PEM is a text-based encoding format that represents certificates and other cryptographic objects with Base64 data and delimiter lines.

A PEM-encoded certificate is a text representation of an X.509 certificate. It uses ASCII characters, a Base64-encoded certificate body, and delimiter lines that identify the object. This makes certificates practical to store in text configuration files. section 8.1.2 section 8.4

Recognizing a PEM certificate

A PEM certificate begins with -----BEGIN CERTIFICATE----- and ends with -----END CERTIFICATE-----. The content between them is Base64 data. A GitHub certificate can be saved as github-cert.pem by piping OpenSSL output into openssl x509. section 8.1.2

echo | openssl s_client -servername github.com -connect
github.com:443 2>/dev/null | openssl x509 
> github-cert.pem

Inspect the command pipeline that opens a TLS connection, extracts its X.509 certificate, and writes the PEM representation. section 8.1.2

PEM describes how certificate data is represented, not what the certificate proves. The certificate still contains a public key and identity metadata; DER provides a binary alternative, while PKCS#12 can store multiple certificates and keys. section 8.4 section 8.1.4

How Software Security for Developers covers it

How deep it goes
Explains delimiters, Base64 encoding, and text storage, but defers certificate validation and trust-chain internals.
Examples
Uses a GitHub certificate, github-cert.pem, PEM delimiters, and an OpenSSL extraction pipeline.
What it assumes
Assumes basic awareness of X.509 certificates and public keys while defining PEM structure from its visible markers.
What you can do after
Operate certificates via the OpenSSL CLI by extracting, saving, and recognizing their PEM representation.
How it connects
Connects X.509 certificates, Base64, public keys, OpenSSL, DER, and PKCS#12.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.