Reading the structure of an X.509 certificate
An X.509 certificate starts with one SEQUENCE that holds exactly three values: the body that gets signed, the signature algorithm, and the signature value. Telling those three apart already solves half of certificate debugging.
Certificate ::= SEQUENCE { tbsCertificate, signatureAlgorithm, signatureValue BIT STRING }
The three parts
- tbsCertificate: the body with issuer, subject, public key and extensions. Its DER bytes are exactly what the signature covers.
- signatureAlgorithm: the algorithm used, such as sha256WithRSAEncryption (1.2.840.113549.1.1.11) or ecdsa-with-SHA256 (1.2.840.10045.4.3.2).
- signatureValue: a BIT STRING. For RSA it holds the signature bytes; for ECDSA it holds a DER SEQUENCE { r, s }.
Field order inside tbsCertificate
| Order | Field | Tag | Meaning |
|---|---|---|---|
| 1 | version | [0] EXPLICIT INTEGER | absent = v1, otherwise value + 1 |
| 2 | serialNumber | INTEGER | unique within the issuer |
| 3 | signature | SEQUENCE | signature algorithm, must match the outer one |
| 4 | issuer | SEQUENCE | issuer distinguished name |
| 5 | validity | SEQUENCE | notBefore and notAfter |
| 6 | subject | SEQUENCE | subject DN, may be empty |
| 7 | subjectPublicKeyInfo | SEQUENCE | algorithm plus BIT STRING key |
| 8 | issuerUniqueID | [1] | rarely used |
| 9 | subjectUniqueID | [2] | rarely used |
| 10 | extensions | [3] EXPLICIT | v3 extension list |
The order is fixed. When a field is omitted the later ones move up, so read tags in order. If the [0] version is absent, the first child is the serial number.
Extensions: OID, critical, OCTET STRING
An extension is SEQUENCE { extnID OID, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }. The OCTET STRING usually contains another DER structure, so the content only appears one level deeper.
- subjectAltName (2.5.29.17): a list of GeneralName values such as dNSName [2], iPAddress [7], rfc822Name [1] and URI [6]. Browsers trust SAN over CN today.
- basicConstraints (2.5.29.19): whether it is a CA and the path length limit. Non-CA certificates carry a critical FALSE.
- keyUsage (2.5.29.15): bit flags such as digitalSignature and keyEncipherment.
- extKeyUsage (2.5.29.37): purpose OIDs such as serverAuth, clientAuth and codeSigning.
- subjectKeyIdentifier and authorityKeyIdentifier: key hashes used to link a chain.
- cRLDistributionPoints and authorityInfoAccess: revocation list and OCSP/CA issuer locations.
How to check it here
Paste a certificate PEM and the structure panel lists version, serial, signature algorithm, issuer, validity, subject, public key and extensions. In the tree you can see the byte offset of each field, and pressing an extension OID narrows the dictionary to that entry.
This tool decodes structure only. It does not check the signature, the chain of trust or whether the certificate is currently valid. Use a dedicated verifier for those.
What people actually check
- That SAN contains the real service domain, and how far a wildcard reaches.
- Whether the two validity times are UTCTime or GeneralizedTime, and whether a year passes 2050.
- Whether keyUsage lacks keyEncipherment while the certificate serves TLS.
- Whether a critical extension carries an OID the client does not understand.
Questions
What if there is no version field?
It is a v1 certificate. version defaults to v1, so DER omits it. When a [0] tag appears, the INTEGER inside plus one is the real version.
Is looking at CN enough?
No. Modern browsers and TLS libraries prefer subjectAltName. CN often remains for display only, and a certificate without SAN can fail validation.
Does the certificate contain the private key?
No. A certificate holds only the public key. The private key lives in a separate file (PKCS#8 and others); a PEM that contains both has been merged by mistake.
Load the certificate sample and find the serial number and SAN nodes.
Open the toolThis guide follows ITU-T X.690 (DER/BER), RFC 5280 (X.509), RFC 5208 (PKCS#8), RFC 5480 (EC public keys), RFC 5915 (EC private keys) and RFC 3279 (ECDSA signatures). Every example is synthetic.