TLS Certificates Explained: CAs, Chains, Expiry
On Monday morning, every visitor to your company's site sees "Your connection is not private". Nobody deployed anything; a certificate expired over the weekend. This lesson explains TLS certificates: what is inside one, how a chain of authorities earns your browser's trust, how clients check it, why it expires so soon and how to fix common failures.
What a certificate contains
Lesson 8 called a certificate a website's ID card, signed by a certificate authority (CA). It is a small file in a standard format, X.509, with these main fields:
- Subject: who it was issued to, such as
CN=example.com(CN means common name). Browsers no longer use it to match names. - Subject Alternative Names (SAN): the names the certificate is valid for, such as
example.comandwww.example.com. A wildcard,*.example.com, stands for exactly one label, one dot-separated part of a name: it coverswww.example.com, notexample.comora.b.example.com. - Public key: the public half of the server's key pair (lesson 7); the private half stays on the server.
- Issuer: the CA that signed it.
- Not Before and Not After: when validity starts and ends, in UTC, which openssl prints as GMT.
- Signature: the CA hashes the other fields and signs the hash with its private key. Anyone can check this digital signature with the CA's public key, and changing one byte breaks it.
In the diagram, notice that the Subject and the SAN list are separate: a name missing from the SAN list fails, whatever the Subject says.
Certificate authorities and the chain of trust
Your operating system or browser ships with a trust store, a built-in list of root certificates from CAs its maker has vetted. A root CA's certificate is self-signed, issued by itself, so it is trusted only because it is in that list.
Public roots don't sign websites directly. Their private keys are kept offline, so a root signs a few intermediate CAs, and an intermediate signs the leaf certificate, the one for your site. If an intermediate's key is stolen, the CA revokes just that intermediate; roots on devices stay put.
In the handshake (lesson 8), the server sends its leaf and the intermediates; the root comes from the client's trust store. In the diagram, follow the colours: each Issuer is the Subject of the certificate to its left, whose public key checks the signature. That link, repeated up to a root you already trust, is the chain of trust.
How a client validates a certificate
Every client, whether a browser, curl or your app's HTTP library, runs these checks whenever a server presents its certificate:
- Name: the host name you asked for is in the leaf's SAN list.
- Dates: now falls between Not Before and Not After, for every certificate in the chain.
- Chain: every signature checks out, and the chain ends at a root in the trust store.
- Revocation: the CA has not cancelled the certificate.
Notice in the flowchart that the checks are gates in a row: one failure means a warning page, or an error in curl and code libraries.
To revoke a certificate is to cancel it early, for example after its private key leaks. CAs publish cancelled certificates in a certificate revocation list (CRL). Chrome and Firefox rarely ask the CA on each visit; they use compact lists their makers push out.
The checks alone don't prove identity, because certificates are public: as lesson 8 showed, the server must also sign the handshake with the private key matching the leaf's public key.
Expiry: short lifetimes and renewal with ACME
Short lifetimes limit the damage: a stolen key or a wrongly issued certificate works only until it expires, and revocation is patchy. The CA/Browser Forum, the group of CAs and browser makers that sets the rules for public certificates, keeps cutting the maximum lifetime:
- 398 days, until 15 March 2026
- 200 days, from 15 March 2026
- 100 days, from 15 March 2027
- 47 days, from 15 March 2029
Let's Encrypt, the free CA from lesson 8, issues 90-day certificates and has announced a move to 45 days. Renewing that often by hand invites outages, so renewal is automated.
ACME (Automatic Certificate Management Environment, RFC 8555) is the protocol for this. An ACME client on your server asks the CA for a certificate, and the CA sets a challenge to prove you control the domain:
- HTTP-01: the client serves a token under
http://your-domain/.well-known/acme-challenge/on port 80, for the CA to fetch. - DNS-01: the client publishes a TXT record (lesson 3) at
_acme-challenge.your-domain, the only challenge that can get a wildcard.
The CA then issues the certificate; the client installs it with its chain and reloads the web server. The Certbot usually sets up a task that runs twice a day and renews certificates nearing expiry; the Caddy web server has ACME built in. Let's Encrypt suggests renewing when a third of the lifetime remains: 30 days for a 90-day certificate.
Common failures and how to fix them
Lesson 8 showed three of these in a browser. curl (lesson 15) reports each as error 60 plus a reason, worded as below in most macOS and Linux builds; Windows' built-in curl words them differently.
| Failure | After curl: (60) | Usual fix |
|---|---|---|
| Expired | SSL certificate problem: certificate has expired | Renew, then fix the automation. If only one user sees it, check their clock. |
| Wrong host name | SSL: no alternative certificate subject name matches target host name | Reissue with every name in the SAN list, or fix which certificate the server picks. |
| Missing intermediate | SSL certificate problem: unable to get local issuer certificate | Send the full chain: leaf first, then intermediates. |
| Self-signed | SSL certificate problem: self-signed certificate | Public site: get one from a public CA. Internal: run your own CA and install its root on your machines. |
A missing intermediate is the sneaky one. Many desktop browsers cope, because they remember intermediates from other sites or fetch the missing one, so the site works in your browser while curl and code libraries fail. With Certbot's files and nginx (lesson 16), point ssl_certificate at the full chain:
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
fullchain.pem holds the leaf followed by the intermediate; cert.pem holds the leaf alone, and pointing nginx at it is the classic cause. Also avoid curl's -k (--insecure): it skips every check, fine for a one-off look but never in a script or app.
Check yourself
Your site works in Chrome, but a partner's Python script fails with "unable to get local issuer certificate". What is the likely cause?
A missing intermediate. Chrome can fill the gap itself, but most libraries use only what the server sends, so the server must send the full chain.
You have a certificate for *.example.com. Which of www.example.com, example.com and api.eu.example.com does it cover?
Only www.example.com. The star stands for exactly one label: example.com has none there and api.eu is two, so add those names to the SAN list.
A root CA's certificate is self-signed, yet browsers trust it. Why don't they trust a self-signed certificate on a website?
Trust comes from the trust store, not the signature. The root was vetted and installed on your device; the website's certificate is in nobody's store, so nothing vouches for it.