opyeb pemcheck

pemcheck · Format

PEM, DER, CRT, CER, CSR — read the label, not the extension

Format · 5 min read

The short answer

PEM is DER binary wrapped in base64 text. .crt, .cer and .pem often contain the same X.509 certificate and differ only in the extension someone chose. A .csr is not a certificate at all: it is a signed request asking a CA to issue one.

DER: tag, length, value

DER (Distinguished Encoding Rules) is the binary encoding of ASN.1 values. Every value is a tag, a length and content, one after another. A certificate parser only has to read those three fields repeatedly.

TagMeaningWhere it appears
0x30 SEQUENCEordered groupthe certificate, tbsCertificate, names, extensions
0x02 INTEGERintegerversion, serial number, RSA modulus
0x06 OIDobject identifieralgorithms, extension types, policies
0x03 BIT STRINGbit stringpublic key, key usage flags, signature value
0x04 OCTET STRINGbyte stringDER inside an extension, key identifiers
0x17 / 0x18timeUTCTime / GeneralizedTime validity

When a length exceeds 128 bytes the length field grows to several bytes. DER forbids abbreviating lengths and forbids encoding the same value two ways, which is why two identical names can be compared byte for byte to decide whether they are the same issuer.

PEM: base64 folded at 64 columns

PEM places base64 between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----, wrapped at 64 characters. The label in the header tells you what the block contains.

Trust the label over the extension

ExtensionUsually holdsWatch out
.pema certificate, key or chaincheck the BEGIN label
.crt / .cerone certificatemay be raw DER instead of PEM
.csra certificate signing requestno validity period or issuer
.keya private keynever share it
.p12 / .pfxcertificate and key (PKCS#12)needs a passphrase; this tool does not read it

Extensions are names an operating system or tool attached. A .cer can be raw DER, and a .pem can contain three certificates. Opening the file and reading the BEGIN label is the only reliable test.

The shape of a certificate

An X.509 certificate has three parts. tbsCertificate holds the version, serial number, signature algorithm, issuer, validity, subject, public key and extensions. Then come the signature algorithm and the signature value. The signature is the issuer's private-key signature over the whole tbsCertificate.

That is why reading a certificate goes subject and issuer first, then validity and SAN, then signature algorithm and fingerprints. The workbench follows the same order.

A CSR is not a certificate

A CSR (Certificate Signing Request) carries a subject, a public key and requested extensions such as SAN, signed with the corresponding private key. It has no issuer, serial number or validity. Those appear only when a CA issues the certificate.

The CSR signature proves “I hold the private key for this public key”. The certificate signature proves “a CA checked this subject information”. They are not the same claim.

Common mistakes

This tool finds PEM blocks, decodes the base64 and reads the DER itself. Blocks it cannot read are listed with a reason, and any private-key header stops processing with a warning.

Questions

Should I send PEM or DER?

Follow what the recipient asks for. PEM is safer for pasting into text or email; DER is common for binary stores and some server configurations. This tool reads PEM.

Are .crt and .cer the same?

Often the content is identical, but not always. Windows tends to use .cer and Linux .crt; the real format is only known by opening the file and checking for a PEM label or binary DER.

What if a PEM file holds several certificates?

Usually the first block is the leaf, then intermediates, then the root. This tool reads each block and links issuers to subjects to judge the order.

Paste one certificate to see its format, block count and structure immediately.

Open the checker

This article follows RFC 5280 and the CA/Browser Forum Baseline Requirements.