Skip to content

Lesson 3 of 9 · 24m

Chains, Trust Stores, and Path Validation

How clients build a path from leaf to trusted root, why chain order breaks only some clients, and why every runtime has its own trust store.

The most confusing TLS bug in the wild is not a bad certificate. It is a certificate that works in Chrome, fails in curl, works in one container, fails in another, and passes every manual inspection. Nine times out of ten, that is chain construction plus trust store divergence.

Path validation is a graph problem

The server presents a leaf certificate and usually one or more intermediates. The client tries to build a path:

leaf -> intermediate(s) -> trusted root in the local trust store

Validation includes signatures, names, validity windows, constraints, key usages, and policy rules. The root normally is not sent by the server; the client must already trust it locally. Sending the root does not make an untrusted client trust it.

Chain order and missing intermediates

Servers must send the leaf first, then intermediates in order. A missing intermediate often works in browsers because they cache intermediates from other sites or fetch them using Authority Information Access. It fails in minimal clients because they only use the presented chain.

Test exactly what the server sends:

openssl s_client -connect api.internal:443 -servername api.internal -showcerts </dev/null

Look for the certificate chain section. If the leaf arrives alone and the issuer is not locally trusted, browsers are masking an operational defect.

There is never just one trust store

On one Linux host you can easily have six different trust stores:

  • the operating system bundle in /etc/ssl/certs,
  • a Java keystore such as cacerts,
  • Python's certifi bundle,
  • a Node.js bundled list or NODE_EXTRA_CA_CERTS,
  • a container image built on a different distribution,
  • browser or application-specific stores.

This is why curl works on the host proves almost nothing about a Java service in a container. The correct question is: which exact verifier is failing, and what trust store does it load?

Cross-signatures are intentional confusion

Public CAs often cross-sign roots or intermediates to support old and new clients. One logical CA can therefore appear in multiple valid paths. A chain may be valid even when it does not match the path in your documentation. Do not replace certificates just because the chain differs; verify whether the presented path reaches the intended trusted root.

For an internal CA, avoid accidental cross-signing complexity unless you need a migration bridge. Complexity here becomes emergency trivia later.

Hostname verification is separate

A valid chain to a trusted root is necessary but insufficient. The client must also verify that the SAN matches the hostname or IP it intended to reach. These are different steps. You can have a perfect chain for the wrong name.

chain valid?          yes
hostname matches?     no
result                failure

Field notes

  • -servername matters: without SNI you may inspect the default certificate on a shared listener.
  • curl -v shows the verification error; --cacert changes only curl's trust, not the system's.
  • Java truststore changes often require application restarts even when the file updates.
  • In containers, update the CA bundle inside the image or mount it deliberately; inheriting host trust is not automatic.
  • Capture the full presented chain during incidents. People delete evidence by fixing the server first.

Was this lesson helpful?

Sign in to rate