Reading one X.509 certificate
A certificate is three parts
The file is a single SEQUENCE with three fields in order: tbsCertificate (what is signed), signatureAlgorithm and signatureValue. The signature covers the DER bytes of the whole tbsCertificate, so changing any field breaks it.
Certificate ::= SEQUENCE { tbsCertificate, signatureAlgorithm, signatureValue }
Field order inside TBSCertificate
The signed part follows this order. After the first three fields (version, serial, signature) come issuer, validity, subject and public key, and the extensions come last.
- version — an integer inside a [0] tag. v1 is omitted and counts from zero.
- serialNumber — an integer chosen by the issuer, shown in hexadecimal here.
- signature — the signature algorithm used for this certificate (the inner copy).
- issuer — the issuer name, an RDNSequence.
- validity — the two instants, notBefore and notAfter.
- subject — the subject name, equal to the issuer for a self-signed certificate.
- subjectPublicKeyInfo — algorithm identifier and the public key bit string.
- extensions — a list inside a [3] tag, present only in v3.
A name is a list of RDNs
A name is SEQUENCE of SET of SEQUENCE{OID, value}. One SET is a relative distinguished name, and several attributes inside it are written joined by a plus sign. The common attributes are C (country), O (organisation), OU (unit) and CN (common name); an e-mail address uses the OID 1.2.840.113549.1.9.1.
The string types vary too: PrintableString, UTF8String, IA5String, BMPString and TeletexString can all appear, so a plain string comparison of names will miss matches. This tool shows each attribute OID with its value and compares issuer to subject on a normalised key.
Times are UTC, in two possible forms
Validity is written as UTCTime (YYMMDDHHMMSSZ) or GeneralizedTime (YYYYMMDDHHMMSSZ). UTCTime uses a two-digit year, read as 19xx from 50 upwards and 20xx below 50, so a certificate that expires after 2050 must use GeneralizedTime.
| Field | Form | Careful |
|---|---|---|
| notBefore | UTCTime or GeneralizedTime | Often set slightly before issuance |
| notAfter | UTCTime or GeneralizedTime | UTC, so the date can differ by a day locally |
| Days left | Computed | Rounded down; the expiry day counts as zero |
An extension is an OID with a value
Each extension has an OID, a critical flag and a value inside an OCTET STRING. When the critical flag is set, a verifier that cannot process the extension must reject the certificate. SAN, Basic Constraints, KeyUsage, EKU and AKI/SKI are the common ones, and the inner structure differs for each.
The extra OCTET STRING around an extension value looks odd at first, but inside it is DER again, so the parser simply takes one more step.
Questions
How do v1, v2 and v3 differ?
v1 has only the basic fields, v2 adds issuer and subject unique identifiers, and v3 can carry extensions. Extensions are valid only in v3, which is what virtually every public TLS certificate is today.
Why is the signature algorithm written twice?
The value inside TBSCertificate is the algorithm covered by the signature; the outer value is the one actually used. A mismatch can be read differently by different verifiers, so it counts as a violation.
Must the serial number be unique?
Unique per issuer. The CA/Browser Forum baseline asks for at least 64 bits of entropy, and predictable serials cause collisions and tracking problems.
Paste a certificate and the fields are laid out in a table, with disagreements flagged.
Open the toolThis article follows RFC 5280 (X.509), RFC 6125 (host name verification), RFC 6960 (OCSP), RFC 7469 (HPKP), RFC 8555 (ACME) and the CA/Browser Forum Baseline Requirements. Every example certificate is synthetic, made for this site, and tied to no real domain.