Free Ebook cover Web Servers 101: How HTTP, DNS, TLS, and Reverse Proxies Work

Web Servers 101: How HTTP, DNS, TLS, and Reverse Proxies Work

New course

13 pages

Certificates and Trust Chains: How Browsers Validate Identity

Capítulo 8

Estimated reading time: 16 minutes

+ Exercise

What a Certificate Proves (and What It Does Not)

When a browser connects to a site over HTTPS, it needs a way to decide whether the server it reached is allowed to represent the domain name in the address bar. A TLS certificate is the primary identity document used for that decision. The certificate does not “prove” that the server is safe, honest, or free of malware. It proves a narrower claim: a trusted authority has attested that a particular public key is authorized to identify a particular subject (most commonly a DNS name such as www.example.com), under specific constraints and for a limited time.

In practice, the browser uses certificates to answer questions like:

  • Is this certificate currently valid (time window, not expired, not before date)?
  • Is it valid for the hostname I’m visiting (name matching rules)?
  • Is it issued by an authority I trust (trust chain to a root)?
  • Has it been revoked or otherwise distrusted (revocation and browser policies)?
  • Is the certificate allowed to be used for server authentication (key usage constraints)?

Understanding how browsers validate identity requires understanding certificate structure, how chains are built, and how trust anchors (roots) are chosen.

Certificate Anatomy: The Fields Browsers Actually Use

Most web certificates follow the X.509 standard. You do not need to memorize every field, but you should know which parts drive browser decisions.

Subject, Subject Alternative Name (SAN), and Name Matching

Historically, certificates used the Subject field (Common Name / CN) to store the hostname. Modern browsers rely on the Subject Alternative Name (SAN) extension instead. A certificate can include multiple DNS names in SAN, such as:

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

  • example.com
  • www.example.com
  • api.example.com

Browsers compare the hostname you typed (or that the page requested) with the SAN entries. If none match, the browser shows a certificate name error.

Wildcard certificates are allowed in limited forms, such as *.example.com, which can match www.example.com and api.example.com but not example.com itself and not deeper levels like a.b.example.com. Browsers apply strict matching rules to avoid ambiguous or overly broad patterns.

Issuer and Signature: Who Vouches for This Certificate?

A certificate includes an Issuer (the authority that signed it) and a digital signature over the certificate contents. The signature allows anyone with the issuer’s public key to verify that the certificate was not altered and that it was indeed signed by that issuer.

Important: the issuer’s name being present is not enough. The browser must be able to verify the signature using a trusted issuer key, directly or through a chain of intermediate certificates.

Validity Period

Certificates have a Not Before and Not After timestamp. Browsers reject certificates outside this window. This is why correct system time matters: if a device clock is wrong, valid certificates can appear expired or “not yet valid.”

Public Key and Key Type

The certificate binds a public key to the subject names. The server proves possession of the matching private key during the TLS handshake. Common public key types include RSA and ECDSA. The browser does not merely accept the key; it checks that the certificate is authorized for server authentication and that the key meets minimum security requirements.

Extensions: Key Usage, Extended Key Usage, Basic Constraints

Extensions are where many security constraints live:

  • Key Usage and Extended Key Usage (EKU) indicate what the certificate may be used for. For websites, EKU typically includes serverAuth.
  • Basic Constraints indicates whether a certificate is a CA certificate (allowed to sign other certificates). End-entity (leaf) certificates must not be CAs.
  • Subject Key Identifier and Authority Key Identifier help link certificates together when building a chain.

Browsers enforce these constraints to prevent misuse, such as a leaf certificate being used to sign other certificates.

Trust Stores: Where Browser Trust Begins

Browsers do not trust “the internet.” They trust a curated set of root CA certificates stored locally in a trust store. A root CA certificate is self-signed, meaning its issuer and subject are the same and it signs itself. Self-signing is not what makes it trusted; being present in the trust store makes it trusted.

Trust stores are managed by operating systems (Windows, macOS, many Linux distributions) and/or by browsers (some browsers ship their own root programs). Root inclusion is governed by strict policies and audits. For you as an operator, the practical implication is: if your certificate chain does not lead to a root that the browser trusts, users will see an error.

Enterprise and Custom Trust Stores

In corporate environments, administrators may install additional root certificates to enable TLS inspection or internal PKI. This changes what “trusted” means on those devices. For developers, this is a common reason why a site might work on a company laptop but fail on a personal phone (or vice versa).

The Trust Chain: Leaf, Intermediate, Root

Most websites use a three-part chain:

  • Leaf (end-entity) certificate: issued to the website hostname(s), contains the site’s public key.
  • Intermediate CA certificate(s): issued by a root (or another intermediate), used to sign leaf certificates.
  • Root CA certificate: trust anchor stored in the browser/OS trust store.

Roots rarely sign leaf certificates directly. Instead, roots sign intermediates, and intermediates sign leaf certificates. This limits exposure: intermediates can be rotated or revoked without replacing the root in every device trust store.

Chain Building: How the Browser Finds a Path to a Trusted Root

When the server presents its certificate during the TLS handshake, it typically includes the leaf certificate and one or more intermediate certificates. The browser then attempts to build a certification path from the leaf up to a trusted root in its trust store.

Chain building is not always a simple “follow the issuer name.” Browsers may consider multiple possible intermediates, cross-signed variants, and cached certificates. The goal is to find a valid path where every signature verifies and every certificate meets constraints.

Key checks during chain validation include:

  • Signature verification at each step (leaf signed by intermediate, intermediate signed by root or another intermediate).
  • Validity period checks for each certificate in the chain.
  • Basic Constraints and path length constraints (ensuring only CA certificates sign others, and not beyond allowed depth).
  • Key usage/EKU constraints at each level.
  • Policy constraints required by the browser (for example, serverAuth EKU for the leaf).

Why Servers Must Send Intermediates (But Not Roots)

Servers should send the intermediate certificates needed to build the chain, but they generally should not send the root certificate. Browsers already have roots in their trust store, and sending roots wastes bytes and can sometimes confuse chain building if the wrong root variant is sent.

A very common misconfiguration is serving only the leaf certificate. Some clients might still succeed by fetching intermediates via AIA (Authority Information Access) URLs embedded in the certificate, but many clients either do not fetch intermediates or do so unreliably. The result is: it works in some browsers and fails in others. Correct configuration is to serve the full chain (leaf + intermediates).

Step-by-Step: What the Browser Does When Validating a Site Certificate

The exact implementation varies by browser and OS, but the validation logic follows a consistent pattern. The steps below focus on identity validation (certificates and trust chains), not on the rest of TLS mechanics.

Step 1: Receive the Certificate Chain from the Server

The server provides the leaf certificate and usually one or more intermediates. The browser parses them and prepares to validate.

Step 2: Check the Hostname Against SAN

The browser compares the requested hostname to the certificate’s SAN entries. If the user visits shop.example.com but the certificate only contains www.example.com, validation fails even if the chain is otherwise trusted.

Step 3: Check Time Validity

The browser checks that the current time is within the leaf’s validity window. It also checks intermediates. An expired intermediate can break validation even if the leaf is current.

Step 4: Build a Chain to a Trusted Root

The browser tries to link the leaf to an intermediate (using issuer/subject names and key identifiers), then link that intermediate upward, until it reaches a root in the trust store. If it cannot reach a trusted root, the certificate is “untrusted.”

Step 5: Verify Signatures Along the Chain

For each link, the browser verifies the signature on the child certificate using the parent certificate’s public key. If any signature fails, the chain is invalid.

Step 6: Enforce Constraints (CA vs Leaf, EKU, Path Length)

The browser ensures that only CA certificates sign other certificates, that the leaf is allowed for server authentication, and that any path length constraints are respected.

Step 7: Check Revocation and Browser Distrust Signals

Browsers use multiple mechanisms to detect certificates that should no longer be trusted (revoked, misissued, or from a CA that has been distrusted). Revocation is nuanced and not always strictly enforced due to performance and privacy tradeoffs, but modern browsers do apply additional safety mechanisms (discussed below).

Step 8: Apply Additional Policies (Transparency, Algorithms, Key Sizes)

Browsers enforce evolving security baselines: minimum key sizes, allowed signature algorithms, and ecosystem requirements such as Certificate Transparency for publicly trusted certificates. If a certificate violates policy, it can be rejected even if the chain is otherwise valid.

Certificate Transparency (CT): Public Logging as an Anti-Misissuance Control

Even trusted CAs can make mistakes or be compromised. Certificate Transparency addresses this by requiring that publicly trusted certificates be logged in append-only public logs. When a CA issues a certificate, it submits it to one or more CT logs and obtains Signed Certificate Timestamps (SCTs). The certificate (or the TLS handshake) then includes SCTs as proof that the certificate was logged.

Browsers can require CT for certain certificates and use CT data to detect misissuance. For operators, the practical takeaway is: if you use a publicly trusted CA, CT is typically handled automatically, but misconfigured issuance flows or unusual certificate types can still run into CT-related errors.

Revocation: CRL, OCSP, and OCSP Stapling

Revocation is the mechanism for saying “this certificate should no longer be trusted” before its expiration date (for example, if the private key is compromised). There are two classic revocation mechanisms:

  • CRL (Certificate Revocation List): a periodically published list of revoked certificate serial numbers.
  • OCSP (Online Certificate Status Protocol): a real-time query to the CA’s responder asking for the status of a specific certificate.

Both have drawbacks. CRLs can be large and slow to download. OCSP queries can add latency and leak browsing behavior to the CA (privacy concern). Because of these issues, browsers often treat revocation checking as “soft-fail” in many scenarios: if the revocation responder is unreachable, the browser may continue rather than block the connection. However, browsers may hard-fail for certain high-risk cases or when additional signals are present.

OCSP Stapling (Practical Improvement)

OCSP stapling lets the server fetch an OCSP response from the CA and “staple” it into the TLS handshake. This reduces latency and improves privacy because the browser does not need to contact the CA directly.

As an operator, enabling OCSP stapling is typically a web server configuration option. It is not a substitute for correct chain configuration, but it can improve reliability and performance of revocation signals.

Must-Staple (When You Want Hard-Fail Behavior)

Some certificates can include a TLS Feature extension indicating “must-staple,” meaning the server is expected to provide a stapled OCSP response. If the browser supports and enforces it, absence of a stapled response can cause failure. This can strengthen security but increases operational risk if stapling breaks. Use it only if you have strong monitoring and a clear reason.

Common Validation Failures and How to Diagnose Them

Certificate errors are often reported to users as generic warnings, but the underlying causes are usually one of a few patterns. Knowing these patterns helps you fix issues quickly.

Name Mismatch

Symptoms: browser error indicates the certificate is not valid for the site name.

Typical causes:

  • Certificate SAN does not include the exact hostname.
  • Using a wildcard that does not match the depth (e.g., expecting *.example.com to cover a.b.example.com).
  • Serving the wrong certificate on a multi-tenant server due to SNI misconfiguration.

Fix: reissue the certificate with correct SANs, or correct SNI/virtual host routing so the right certificate is served for the hostname.

Incomplete Chain (Missing Intermediate)

Symptoms: works on some devices but fails on others; errors like “unable to get local issuer certificate” in tooling.

Cause: server sends only the leaf certificate (or the wrong intermediate), and the client cannot build a chain to a trusted root.

Fix: configure the server to present the full chain (leaf + intermediates). Do not rely on clients fetching intermediates.

Expired Certificate (Leaf or Intermediate)

Symptoms: clear “expired” error.

Causes:

  • Leaf certificate not renewed in time.
  • Intermediate in the served chain is expired even though a newer intermediate exists.
  • Client device clock is incorrect.

Fix: renew and deploy the correct chain; ensure automation renews before expiry; verify that the server is serving the updated intermediate bundle.

Untrusted Root / Private PKI

Symptoms: “certificate not trusted” or “unknown issuer.”

Causes:

  • Using an internal CA without installing the root in client trust stores.
  • Using a CA that is not publicly trusted by that platform.
  • Old devices missing newer roots (common with legacy mobile/embedded clients).

Fix: for public sites, use a publicly trusted CA with broad compatibility; for internal sites, distribute the internal root to managed devices; consider compatibility requirements for older clients.

Policy Failures (CT, Algorithms, Key Sizes)

Symptoms: certificate appears valid but browser still blocks; errors referencing policy or transparency.

Causes:

  • Missing required SCTs for CT.
  • Using deprecated signature algorithms or insufficient key sizes.
  • CA or intermediate has been distrusted by the browser vendor.

Fix: reissue with a compliant CA and modern parameters; ensure your issuance flow includes CT; keep server software and certificate automation current.

Practical: Inspecting Certificates and Chains with Common Tools

Being able to inspect what your server is actually presenting is essential. The following steps show how to view the leaf certificate, intermediates, and validation results.

Step-by-Step with OpenSSL: See the Presented Chain

Use openssl s_client to connect and print certificates:

openssl s_client -connect example.com:443 -servername example.com -showcerts

What to look for:

  • Multiple BEGIN CERTIFICATE blocks: leaf first, then intermediates.
  • The subject= and issuer= lines for each certificate.
  • Whether the chain includes the expected intermediate(s).

If you want to verify using a specific CA bundle (useful in containers or minimal systems):

openssl s_client -connect example.com:443 -servername example.com -showcerts -verify_return_error -CAfile /path/to/ca-bundle.crt

Errors like unable to get local issuer certificate usually indicate missing intermediates or an unknown root.

Step-by-Step: Extract and Inspect SAN

After copying the leaf certificate to a file (for example leaf.pem), inspect SAN:

openssl x509 -in leaf.pem -noout -text

Find the X509v3 Subject Alternative Name section and confirm the hostname you need is listed.

Step-by-Step: Verify a Chain Offline

If you have the leaf and intermediate files, you can verify locally:

cat intermediate.pem > chain.pem
openssl verify -CAfile /path/to/ca-bundle.crt -untrusted chain.pem leaf.pem

This helps distinguish “server didn’t send the chain” from “chain truly cannot reach a trusted root.”

Operational Guidance: Deploying Certificates Correctly on Web Servers and Proxies

In real deployments, certificates are often installed on a reverse proxy or load balancer rather than on the application server. Regardless of where TLS terminates, the same identity validation rules apply to clients, so your edge must present the correct certificate and chain.

Use the Correct File: Leaf vs Full Chain

Many CAs provide multiple download options, such as:

  • Certificate (leaf only)
  • CA bundle (intermediate(s))
  • Full chain (leaf + intermediate(s))

Most servers expect you to configure a “full chain” file for the certificate field and a separate private key file. If you only configure the leaf, some clients will fail.

Multi-Domain and Multi-Tenant Considerations

If one IP address serves multiple hostnames, the server must select the correct certificate based on the requested hostname. This selection is typically driven by SNI (Server Name Indication). Misrouting here produces name mismatch errors even if the certificate itself is fine.

Practical checks:

  • Test with -servername in OpenSSL to ensure SNI is used.
  • Verify each hostname returns the correct leaf certificate and chain.

Automation and Renewal Safety

Because certificates expire, renewal should be automated. Operationally, the most common renewal failure is not issuance but deployment: the new certificate is obtained but the server continues serving the old one, or serves an outdated intermediate chain. Monitoring should check the certificate actually presented to clients, not just what exists on disk.

Practical monitoring ideas:

  • Alert on days-to-expiry for the presented leaf certificate.
  • Alert on chain completeness (at least one intermediate presented when expected).
  • Alert on hostname coverage (SAN includes required names).

Identity Levels: DV, OV, EV (What Changes for Browsers)

Certificates can be issued under different validation regimes:

  • Domain Validation (DV): CA verifies control of the domain (for example via DNS or HTTP challenge). This is the most common for websites.
  • Organization Validation (OV): CA verifies domain control plus organization details.
  • Extended Validation (EV): stricter identity verification procedures.

From a browser’s technical validation perspective, DV/OV/EV certificates all rely on the same chain validation mechanisms. The main differences are in CA issuance procedures and how (or whether) browsers present identity UI. Modern browsers generally emphasize secure transport and correct domain binding rather than prominent EV indicators.

Putting It Together: A Mental Model for Troubleshooting

When a browser says a site’s certificate is invalid, you can usually categorize the failure by asking four questions:

  • Does the certificate cover the hostname? Check SAN and wildcard rules.
  • Is it currently valid? Check expiration and device time.
  • Can the browser build a chain to a trusted root? Ensure intermediates are served and roots are trusted on that platform.
  • Does it meet modern browser policy? Consider CT, revocation signals, algorithms, and CA distrust events.

This model maps directly to the browser’s validation steps and helps you move from a vague warning to a concrete fix.

Now answer the exercise about the content:

A site works in some browsers but fails in others with errors suggesting it cannot build a chain to a trusted issuer. Which server-side change is the most appropriate fix?

You are right! Congratulations, now go to the next page

You missed! Try again.

If the server only serves the leaf certificate, some clients cannot reach a trusted root. The fix is to serve the full chain (leaf plus intermediates). Roots are already in trust stores and generally should not be sent.

Next chapter

TLS Handshake in Words: Key Exchange, Session Keys, and SNI

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.