Why every cert file looks different
.pem, .crt, .key, .csr, .p12, .jks — the same underlying objects
(certificates and keys) ship under a confusing pile of extensions and two
encodings. This reference explains what each extension actually holds, whether
it is text or binary, and the one command that dumps it so you never guess again.
How it works
Two encodings underlie nearly everything:
- DER — the raw binary ASN.1 encoding.
- PEM — that same DER, base64-encoded, wrapped in
-----BEGIN ...-----/-----END ...-----lines so it is safe to paste into text.
Extensions are a hint, not a guarantee. The reliable test is the first bytes:
-----BEGIN CERTIFICATE----- → PEM (base64 text)
0x30 0x82 ... → DER (binary)
Bundle formats package multiple objects: PKCS#12 (.p12/.pfx) holds a key
plus its certificate chain in one password-protected binary file, while JKS
(.jks) is Java’s keystore managed by keytool. PEM files can also simply
concatenate several certificates to form a chain.
Tips and notes
- Identify format by content, not extension: look for the
-----BEGINmarker. - Convert with OpenSSL:
openssl x509 -in cert.der -inform der -out cert.pem. - Keep private keys (
.key) permission-locked and never commit them. - Prefer PKCS#12 (
.p12) over legacy JKS for new Java keystores.