opyeb asn1lab

asn1lab · Certificates

Reading the structure of an X.509 certificate

Three parts, tbsCertificate field order, extension OIDs and SAN

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

  1. tbsCertificate: the body with issuer, subject, public key and extensions. Its DER bytes are exactly what the signature covers.
  2. 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).
  3. signatureValue: a BIT STRING. For RSA it holds the signature bytes; for ECDSA it holds a DER SEQUENCE { r, s }.

Field order inside tbsCertificate

OrderFieldTagMeaning
1version[0] EXPLICIT INTEGERabsent = v1, otherwise value + 1
2serialNumberINTEGERunique within the issuer
3signatureSEQUENCEsignature algorithm, must match the outer one
4issuerSEQUENCEissuer distinguished name
5validitySEQUENCEnotBefore and notAfter
6subjectSEQUENCEsubject DN, may be empty
7subjectPublicKeyInfoSEQUENCEalgorithm plus BIT STRING key
8issuerUniqueID[1]rarely used
9subjectUniqueID[2]rarely used
10extensions[3] EXPLICITv3 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.

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

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 tool

This 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.