Skip to content
X.509 Certificates
step 1/5

Reading — step 1 of 5

Read

~1 min readX.509 & PKI Foundations

X.509 Certificates

X.509 is the cert format. It's encoded as ASN.1 DER, almost always wrapped in PEM (base64) for display:

-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJALm...
-----END CERTIFICATE-----

Inside, an X.509 v3 certificate has:

TBSCertificate (To-Be-Signed):
    version
    serial number
    signature algorithm
    issuer name (Distinguished Name)
    validity {notBefore, notAfter}
    subject name (Distinguished Name)
    SubjectPublicKeyInfo {algorithm, public key}
    extensions (v3 only — KeyUsage, ExtKeyUsage, BasicConstraints, SAN, AKI, SKI, etc.)
signature algorithm
signature value

Distinguished Name (DN): CN=bank.com, O=Bank Inc, C=US. Once important; today CN deprecated for hostnames in favor of Subject Alternative Name (SAN).

Critical extensions:

  • BasicConstraints: CA:TRUE for CA certs (allowed to sign other certs); CA:FALSE for end-entity. Path length constraint here.
  • KeyUsage: digitalSignature, keyEncipherment, certSign, etc. — what the public key may be used for.
  • ExtKeyUsage: serverAuth (TLS server), clientAuth (TLS client), codeSigning, emailProtection.
  • Subject Alternative Name (SAN): list of hostnames (*.bank.com, bank.com, www.bank.com). The actual hostname check.
  • Authority Key Identifier (AKI): hash of issuer's pubkey.
  • Subject Key Identifier (SKI): hash of own pubkey.

Path validation (RFC 5280):

  • Verify each link's signature.
  • Check validity dates.
  • Check BasicConstraints (each non-leaf MUST be CA, leaf MUST NOT be CA).
  • Check KeyUsage allows the operation.
  • Check name constraints (some intermediates restricted to certain domains).
  • Apply revocation checks.

Implementation: use cryptography (Python), golang.org/x/crypto/x509, rustls-webpki, OpenSSL. Don't roll your own.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…