Opscraft
How SSL/TLS works · Lesson 2 of 8 · 6 min read

Certificates and the chain of trust

What's in an X.509 certificate

Subject:        CN = shop.example.com
Subject Alternative Names: DNS:shop.example.com, DNS:www.shop.example.com
Issuer:         C = US, O = Amazon, CN = Amazon RSA 2048 M02
Validity:       Not Before: Oct  1 00:00:00 2026 GMT
                Not After : Apr 16 23:59:59 2027 GMT
Public Key:     RSA 2048 bit (or EC P-256)
Key Usage:      Digital Signature, Key Encipherment
Extended Key Usage: TLS Web Server Authentication
Signature:      sha256WithRSAEncryption (by the issuer)
  • Subject Alternative Names (SANs) are what clients check against the hostname. Browsers ignore the CN for this — a certificate whose name is only in the CN fails.
  • A wildcard *.example.com matches exactly one label: api.example.com, not example.com and not a.b.example.com. Put the apex in the SANs too.
  • The private key never leaves the server (or the HSM / ACM). The certificate itself is public.
Enlarge diagramCertificate SANs*.example.com, example.comapi.example.comexample.coma.b.example.comexample.orgmatches *.example.comonly because it is listed itselftwo labels: not covereddifferent domain
Figure 1. Which names a certificate covers. A wildcard matches exactly one label, so add the bare domain as its own SAN.
Swipe sideways to see all of it, or tap to open it full screen.

Certificate authorities and the chain

A certificate authority (CA) vouches that a public key belongs to a domain by signing a certificate after domain validation (DV), or organisation/extended validation (OV/EV).

Enlarge diagramALREADY ON THE CLIENTSENT BY THE SERVER (THE "FULL CHAIN")Root CAself-signed · kept offlineIntermediate CAsigns day to dayshop.example.comthe leaf (server)certificatesignssignsOS, browser, Java cacerts,ca-certificates in imagesleaf + intermediate. Forget the intermediate and curl, Javaand Python fail with "unable to get local issuer certificate".
Figure 2. The chain of trust. The server sends its own certificate plus the intermediate; the client already has the root in its trust store.
Swipe sideways to see all of it, or tap to open it full screen.
  • Root CAs are self-signed and pre-installed in trust stores (OS, browsers, Java's cacerts, container images' ca-certificates). Their keys are kept offline.
  • Intermediate CAs do day-to-day signing so the root key stays offline and can't be exposed; an intermediate can be revoked without replacing roots everywhere.
  • The server must send its leaf certificate plus the intermediates (the "chain" / "fullchain"). The client builds a path to a root it trusts and checks every signature, validity period, name, and key usage.

Missing intermediate is the most common chain bug: browsers often fetch missing intermediates themselves (AIA fetching) or have them cached, so the site "works in Chrome", while curl, Java, Python and mobile apps fail with "unable to get local issuer certificate". Always serve the full chain.

Getting a certificate

  1. Generate a key pair and a CSR (certificate signing request) containing your public key and the names you want.
  2. The CA validates domain control — by an HTTP file, a DNS TXT/CNAME record, or email.
  3. The CA returns the signed certificate (plus intermediates).
openssl req -new -newkey rsa:2048 -nodes -keyout shop.key -out shop.csr \
  -subj "/CN=shop.example.com" -addext "subjectAltName=DNS:shop.example.com,DNS:www.shop.example.com"

With ACME (Let's Encrypt, ZeroSSL) the process is automated:

  • HTTP-01 — the CA fetches a token from http://<domain>/.well-known/acme-challenge/ on port 80. Simple, but can't issue wildcards and needs port 80 reachable.
  • DNS-01 — you create a _acme-challenge TXT record. Works for wildcards and internal-only hosts; needs DNS API access (Route 53 IAM permissions).
  • TLS-ALPN-01 — validation on port 443 during a special handshake.

Public certificate lifetimes are shrinking across the industry. The CA/Browser Forum capped publicly trusted certificates at 200 days from March 2026, falling to 100 days in 2027 and 47 days in 2029. Let's Encrypt issues 90-day certificates by default, moving to 64 days in February 2027 and 45 days in February 2028 (45-day certificates are already available as an opt-in profile). Short lifetimes make automation mandatory.

Enlarge diagramACME cliente.g. cert-managerLet's EncryptRoute 53your DNSorder a certificatefor *.shop.example.comprove it: publish this tokencreate TXT _acme-challengelooks up the TXT recordvalidated: here is the certificateclean up the TXT record
Figure 3. Getting a certificate with ACME DNS-01 validation: prove you control the domain by creating a TXT record. Works for wildcards and internal hosts.
Swipe sideways to see all of it, or tap to open it full screen.

Revocation and transparency

  • Revocation — CRLs and OCSP let CAs mark compromised certificates as invalid; OCSP stapling has the server attach a fresh OCSP response to the handshake. In practice browser revocation checking is weak, which is another reason short-lived certificates are winning.
  • Certificate Transparency (CT) — every publicly trusted certificate is logged in public append-only logs. Monitor CT (crt.sh, Cert Spotter or similar services) to detect certificates issued for your domains that you didn't request.
  • CAA DNS records restrict which CAs may issue for your domain: example.com. CAA 0 issue "amazon.com".

File formats

Format Encoding Typical use
PEM (.pem, .crt, .key) Base64 text with -----BEGIN CERTIFICATE----- Linux, Nginx, Kubernetes, ACM import
DER (.der, .cer) Binary Windows, Java sometimes
PKCS#12 / PFX (.p12, .pfx) Binary bundle: cert + chain + private key, password-protected Windows/IIS, Java keystores
JKS Java keystore Older Java apps
openssl x509 -in cert.pem -noout -text                  # inspect: SANs, issuer, dates
openssl x509 -in cert.der -inform der -out cert.pem     # DER → PEM
openssl pkcs12 -in bundle.pfx -out all.pem -nodes       # PFX → PEM
cat server.crt intermediate.crt > fullchain.pem         # Nginx wants leaf first, then intermediates
openssl rsa -in shop.key -noout -modulus | openssl md5  # these two must match:
openssl x509 -in shop.crt -noout -modulus | openssl md5 # key belongs to the cert