Course contents · Lesson 18 of 22

TLS Certificates Explained: CAs, Chains, Expiry

Networks for Engineers · Lesson 18 of 22 · 11 min Engineer

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.com and www.example.com. A wildcard, *.example.com, stands for exactly one label, one dot-separated part of a name: it covers www.example.com, not example.com or a.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.

A leaf certificate in X.509 format with seven labelled fields. Subject: CN=example.com, who it is for, an older field. Subject Alt Names: example.com and www.example.com, highlighted as the names browsers match. Issuer: CN=Example Trust TLS CA, the CA that signed it. Not Before: Oct 12 00:00:00 2026 GMT. Not After: Apr 20 23:59:59 2027 GMT, the expiry, renew well before it. Public key: an EC 256-bit key, half of the server's key pair. Signature: the CA's seal over all the fields. Names, dates and key bytes are illustrative
The browser matches your address against the SAN list; the signature seals every field.

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.

Three certificates joined by arrows labelled signs. The root CA, Example Trust Root, is self-signed: its subject and issuer are the same, and its key is kept offline. It signs the intermediate CA, Example Trust TLS CA, whose issuer is Example Trust Root. The intermediate signs the leaf certificate for example.com, whose issuer is Example Trust TLS CA. The root is already on your device in its trust store; the server sends the intermediate and the leaf during the TLS handshake. CA names are illustrative
Trust flows from a root already on your device, through the intermediate, to the site.

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:

  1. Name: the host name you asked for is in the leaf's SAN list.
  2. Dates: now falls between Not Before and Not After, for every certificate in the chain.
  3. Chain: every signature checks out, and the chain ends at a root in the trust store.
  4. 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.

Flowchart. The server sends its certificate chain, then the browser asks four questions in turn. Is the name in the SAN list? If no, a wrong name warning, NET::ERR_CERT_COMMON_NAME_INVALID. Is today within the dates? If no, expired or not yet valid, NET::ERR_CERT_DATE_INVALID. Does the chain end at a trusted root? If no, untrusted or broken chain, NET::ERR_CERT_AUTHORITY_INVALID. Not revoked by the CA? If no, a revoked warning, NET::ERR_CERT_REVOKED. If all four pass, the padlock shows and encrypted HTTP flows. The codes are Chrome's; other tools word them differently
Every gate must say yes; one no shows a warning instead of the site.

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.

FailureAfter curl: (60)Usual fix
ExpiredSSL certificate problem: certificate has expiredRenew, then fix the automation. If only one user sees it, check their clock.
Wrong host nameSSL: no alternative certificate subject name matches target host nameReissue with every name in the SAN list, or fix which certificate the server picks.
Missing intermediateSSL certificate problem: unable to get local issuer certificateSend the full chain: leaf first, then intermediates.
Self-signedSSL certificate problem: self-signed certificatePublic 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.