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.commatches exactly one label:api.example.com, notexample.comand nota.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.
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).
- 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
- Generate a key pair and a CSR (certificate signing request) containing your public key and the names you want.
- The CA validates domain control — by an HTTP file, a DNS TXT/CNAME record, or email.
- 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-challengeTXT 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.
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