CertiMonitor

Blog

How TLS certificates work, and why validation fails

Jaime Guerrero · · 6 min read

A TLS certificate does one job: it lets a client confirm that the server it reached is really the one for the name it asked for. Everything else, the chain, the trust store, the extensions, exists to make that one statement checkable by a client that has never seen the server before.

This is how that check works, and the specific ways it fails.

What happens in the handshake

With TLS 1.3, the client opens the connection with a ClientHello. Among other things it carries the hostname in the Server Name Indication (SNI) extension, so a server hosting many sites knows which certificate to send. The server answers with:

  1. its certificate and the intermediates it was issued under (the Certificate message),
  2. a signature over the handshake so far, made with the certificate's private key (CertificateVerify),
  3. a Finished message that seals the handshake.

The CertificateVerify signature is the part people forget. Anyone can copy a public certificate and send it. Only the holder of the matching private key can produce that signature, so the certificate proves nothing unless the signature checks out against the public key inside it.

The client then validates the certificate itself. If any step fails, the connection is aborted before a single byte of application data is sent.

What's inside a certificate

Here is the certificate github.com was serving when I wrote this, read with openssl x509:

$ echo | openssl s_client -connect github.com:443 -servername github.com 2>/dev/null \
    | openssl x509 -noout -subject -issuer -dates -ext subjectAltName,keyUsage,extendedKeyUsage,authorityInfoAccess
subject=CN=github.com
issuer=C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication CA DV E36
notBefore=Sep  1 00:00:00 2026 GMT
notAfter=Nov 29 23:59:59 2026 GMT
X509v3 Key Usage: critical
    Digital Signature
X509v3 Extended Key Usage:
    TLS Web Server Authentication
Authority Information Access:
    CA Issuers - URI:http://crt.sectigo.com/SectigoPublicServerAuthenticationCADVE36.crt
    OCSP - URI:http://ocsp.sectigo.com
X509v3 Subject Alternative Name:
    DNS:github.com, DNS:www.github.com

What each part is for:

FieldWhat the client does with it
Subject Alternative Name (SAN)The list of names the certificate is valid for. This is the only place browsers look for the hostname.
Subject (CN)Kept for compatibility. Browsers stopped matching hostnames against the CN years ago, so a certificate whose name is only in the CN fails.
IssuerWhich CA signed it. The client uses this to find the next certificate up the chain.
notBefore / notAfterThe validity window. Outside it the certificate is rejected, which also means a client with a wrong clock rejects valid certificates.
Key Usage / Extended Key UsageWhat the key may be used for. A server certificate needs TLS Web Server Authentication.
Authority Information AccessWhere to download the issuer's certificate, and where revocation status was traditionally checked.

The validity window here is 90 days, already shorter than the current maximum. Lifetimes keep dropping, which matters for renewal but doesn't change any of the mechanics below.

Building the chain

Clients don't trust a server certificate directly. They trust a small set of root certificates, and accept a server certificate only if they can build a path of signatures from it to one of those roots.

github.com sends this chain (trimmed to subjects and issuers):

 0 s:CN=github.com
   i:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication CA DV E36
 1 s:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication CA DV E36
   i:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication Root E46
 2 s:C=GB, O=Sectigo Limited, CN=Sectigo Public Server Authentication Root E46
   i:C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust ECC Certification Authority

Certificate 0 is the leaf. Certificate 1 is the intermediate that signed it. Certificate 2 is interesting: "Root E46" is a root in its own right, but here it's presented as signed by an older root, USERTrust ECC. That's a cross-sign. A client whose trust store already has Root E46 stops at certificate 2. An older client that only knows USERTrust follows the cross-sign one step further. One chain serves both.

Two rules fall out of this:

  • The server must send its intermediates. The client usually has the root, but nobody is guaranteed to have the intermediate.
  • The root itself doesn't need to be sent. Clients ignore it and use their own copy, because a root you send can't vouch for itself.

Trust stores differ

"Trusted" always means trusted by a specific store. The main ones are Mozilla's (used by Firefox and copied into most Linux distributions as ca-certificates), the Chrome Root Store, Apple's and Microsoft's. Programming languages and runtimes add their own: Java ships cacerts, Python's requests uses certifi, Node.js bundles Mozilla's list.

This is why a certificate can work in every browser and still fail somewhere else. A container image built two years ago carries a two-year-old trust store. When a CA moves to a new root, old stores don't have it, and those clients fail until they're updated or the server sends a cross-signed chain they can follow.

Why validation fails

These are the common failures, reproduced against badssl.com's test hosts, which are broken on purpose. The command for each is the same, with the hostname changed:

echo | openssl s_client -connect HOST:443 -servername HOST -verify_hostname HOST
ProblemWhat openssl reportsUsual cause
Expiredverify error:num=10:certificate has expiredRenewal didn't happen, or the server still serves the old file
Self-signedverify error:num=18:self-signed certificateA default or test certificate left in place
Missing intermediateverify error:num=20:unable to get local issuer certificate then num=21:unable to verify the first certificateThe server is configured with the leaf only, not the full chain
Wrong nameverify error:num=62:hostname mismatchThe certificate doesn't list the name that was requested

The hostname case at wrong.host.badssl.com shows a detail about wildcards. The certificate is for *.badssl.com, and a wildcard matches exactly one label. It covers wrong.badssl.com but not wrong.host.badssl.com, and it doesn't cover the bare badssl.com either.

The missing-intermediate case is the one that confuses people most, because browsers often hide it. Firefox ships a preloaded set of intermediates, and Chrome on some platforms downloads a missing one from the Authority Information Access URL. The site looks fine in the browser and then fails in curl, in a mobile app or in a payment provider's webhook client, none of which do that. Always test the chain with something stricter than a browser.

Revocation

A certificate can be revoked before it expires, for example after its private key leaks. Clients learn about revocation in two ways:

  • CRLs, lists of revoked serial numbers that the CA publishes and clients download.
  • OCSP, where the client asks the CA about one certificate. Servers can attach a recent signed answer to the handshake themselves, which is called OCSP stapling.

In practice browsers don't do live checks for every connection. Chrome relies on CRLSets, a curated list it pushes to the browser, and Firefox on CRLite, a compressed set of all revocations. OCSP is also fading: it tells the CA which sites each visitor opens, and Let's Encrypt shut its OCSP service down entirely on August 6, 2025, publishing CRLs instead. The weakness of revocation is one of the reasons certificate lifetimes are being cut.

Certificate Transparency

Every publicly trusted certificate is now logged in public Certificate Transparency (CT) logs before it's used. The log returns a signed receipt, a Signed Certificate Timestamp (SCT), and the CA embeds it in the certificate. github.com's certificate carries two of them, from two different logs:

CT Precertificate SCTs:
    Signed Certificate Timestamp:
        Version   : v1 (0x0)
        Log ID    : D7:6D:7D:10:D1:A7:F5:77:C2:C7:E9:5F:D7:00:BF:F9:
                    82:C9:33:5A:65:E1:D0:B3:01:73:17:C0:C8:C5:69:77
        Timestamp : Sep  1 00:10:32.017 2026 GMT

Chrome and Safari reject publicly trusted certificates without valid SCTs. The point is that no CA can issue a certificate for your domain in secret: it shows up in the logs, which anyone can search. That also makes CT one of the best tools for finding certificates you forgot you had, which I cover in certificate lifecycle management.

Checking a host properly

To test a host the way a strict client would:

echo | openssl s_client -connect example.com:443 -servername example.com \
    -verify_hostname example.com -showcerts

Look at the last lines for Verify return code: 0 (ok), and at the Certificate chain section to see exactly what the server sends. Leave out -servername and many servers send a default certificate instead of yours. Leave out -verify_hostname and openssl won't check the name at all.

The free check runs the same validation from the outside: expiry, chain, trust and whether the certificate covers the name you entered, along with the domain's registration and email records.

Sources