TLS: handshake, chains and trust, SNI, rotation, mTLS, and reading openssl s_client

Almost every TLS failure is path-building: the server must send leaf plus intermediates, the client must reach a root it holds, and the name must match. Browsers hide the missing intermediate; curl does not.

Read the briefing
About 4 min to read 7 drills

What to remember

  1. Serve the full chain, then test with something that is not a browser. Browsers repair chains from cache. curl, Java and mobile SDKs do not.
  2. Roots are never sent; intermediates always are. 'unable to get local issuer certificate' means the server's chain file is wrong.
  3. -servername or you get the default certificate. SNI selects the cert before any cert is sent. Testing a bare IP tests nothing.
  4. Expiry outages are monitoring failures. Automation fails silently. Alert externally at 14 and 7 days.
  5. Short lifetimes beat revocation. Revocation checking is inconsistent everywhere; expiry is the control that works.

The big picture

TLS is where "the site is down" meets certificates: expired chains, missing intermediates, wrong SNI, and mismatched trust stores cause a steady stream of outages that are trivial to prevent and painful to debug under pressure. Interviewers test whether you understand the handshake enough to read openssl s_client, reason about chains and rotation, and design mTLS without breaking everything.

The mental model

A TLS connection is an agreement built from three things: a key exchange that yields a shared secret, a certificate chain that lets the client tie the server's public key to a name it trusts, and the ciphers used afterwards. Almost every failure is in the middle part: the client cannot build a path from the server's leaf to a root it trusts, or the name does not match. Debug by asking "what did the client actually receive, and what does it trust?"

In depth

The handshake, 1.3 versus 1.2

TLS 1.3 completes a full handshake in one round trip: the client sends ClientHello with supported groups and its key share (plus SNI naming the host it wants); the server answers with ServerHello, its key share, the encrypted certificate chain, and Finished; the client verifies and sends Finished, and application data flows. Resumption with a PSK can be 0-RTT (with replay caveats). TLS 1.2 needed two round trips and negotiated cipher suites that mixed key exchange, authentication, and encryption; 1.3 removed RSA key exchange, static DH, and weak ciphers, and made forward secrecy mandatory. Practical consequences: latency (1-RTT matters at scale), fewer misconfiguration options, and the certificate is encrypted in 1.3 so middleboxes cannot read it.

SNI (Server Name Indication) is the plaintext hostname in ClientHello that lets one IP serve many certificates; a load balancer or ingress picks the certificate from it. curl https://1.2.3.4 without a Host or SNI often gets the default certificate and a name mismatch. Encrypted ClientHello is arriving to hide SNI.

Chains, trust, and the intermediate that was not sent

The server presents a leaf certificate and should present the intermediates that link it to a root the client already has in its trust store. Roots are never sent (and are ignored if they are). The most common outage after a certificate renewal is a server configured with the leaf only: browsers often fix it up via cached intermediates or AIA fetching, while curl, Java clients, and mobile apps fail with "unable to get local issuer certificate". openssl s_client -connect host:443 -servername host -showcerts shows exactly what the server sends; Verify return code: 21 (unable to verify the first certificate) means the chain is incomplete on the server, code 10 means expired, code 62 means hostname mismatch (with -verify_hostname).

Trust stores differ by client: the OS store, the browser store, Java's cacerts, a container image's ca-certificates package. A private CA works only on clients that carry its root; a corporate proxy that re-signs traffic breaks pinned clients. Validity is short by design now (public certificates are moving toward ~90-day and shorter lifetimes), so rotation must be automated.

Rotation, mTLS, and revocation

Rotation: automate issuance (ACME with cert-manager, cloud managed certificates) and reload without downtime (most servers reload on SIGHUP or watch the file; Kubernetes ingress controllers pick up Secret changes). Alert on expiry at 14 and 7 days using an external check, because the failure mode of automation is silence. mTLS: the server also requests a client certificate; identity becomes the certificate's SAN, and you need a private CA, short-lived client certs, and a distribution mechanism (SPIFFE/SPIRE, a service mesh). The costs are operational: every client needs a cert, rotation must be automated, and revocation of a compromised client cert is hard, which is why short lifetimes beat revocation lists. Revocation in practice: CRLs are large and slow, OCSP is a privacy and availability problem, OCSP stapling helps, and browsers use their own summary mechanisms; for infrastructure, design so a certificate's lifetime is short enough that revocation rarely matters.

Myths and facts

Myth: The server should send the root certificate too.

Fact: Roots come from the client's trust store; sending them is wasted bytes. Send the leaf and the intermediates.

Myth: It works in the browser, so the certificate is fine.

Fact: Browsers fix incomplete chains with cached intermediates; curl, Java, and mobile SDKs do not. Test with openssl s_client.

Myth: TLS 1.3 is just faster 1.2.

Fact: It removed insecure key exchanges and ciphers, made forward secrecy mandatory, encrypts the certificate, and changed the handshake to one round trip.

Myth: Revoking a certificate reliably stops its use.

Fact: Revocation checking is inconsistent across clients; short lifetimes are the dependable control.

Myth: mTLS is just turning on client certificates.

Fact: It is a PKI: issuance, distribution, rotation, and identity mapping for every client; the flag is the easy part.

How pros do it

  • Serve the full chain (leaf + intermediates) and test with openssl s_client from a non-browser client after every rotation.
  • Automate issuance and renewal (ACME/cert-manager) and monitor expiry externally at 14 and 7 days.
  • Prefer TLS 1.3, disable 1.0/1.1, and use a modern cipher list; test with a scanner.
  • Use SNI-aware health checks and load-balancer configuration; never test TLS against a bare IP without -servername.
  • For mTLS, use short-lived certificates issued by an automated CA (SPIFFE/SPIRE or a mesh) rather than long-lived manual ones.

Questions people ask

curl says 'unable to get local issuer certificate' but the browser is happy. What is wrong?

The server is sending only its leaf certificate. Roots live on the client and intermediates must come from the server; the browser found the missing intermediate in its cache and curl, Java and mobile SDKs never will. Add the intermediate to the server's chain file, reload, and prove it with openssl s_client -showcerts from a non-browser client.

What actually changed between TLS 1.2 and 1.3?

One round trip instead of two, forward secrecy always, and the insecure options gone. The client sends its key share in the first message, so the server can answer with its own share, an encrypted certificate and Finished at once; RSA key transport and static Diffie-Hellman were removed so a stolen private key cannot decrypt recorded traffic. The caveats worth saying: SNI is still plaintext, and 0-RTT resumption is replayable, so it is gated to idempotent requests.

How do I check what certificate a server actually presents?

openssl s_client -connect host:443 -servername host -showcerts </dev/null, then read the chain and the 'Verify return code' line. It prints exactly what the server sent, from the leaf upward, and the code names the failure: 21 is a missing intermediate, 10 expired, 62 a hostname mismatch. The caveat: without -servername you are testing the default certificate, not the one your clients get.

Why does the certificate for a different site appear when I hit the load balancer IP?

No SNI was sent, so the balancer returned its default certificate. The hostname travels in the ClientHello and the balancer picks the certificate from it before any certificate goes out; connect by IP and it has nothing to pick with. Add -servername to openssl, or use curl --resolve so the name, SNI and certificate check stay honest while you pin the address.

How often should we rotate certificates?

As often as automation allows, and never by hand. Public certificates are moving to about 90 days or less and internal mTLS certificates are typically hours to days, because a short lifetime is the revocation mechanism that actually works. The caveat: rotation is only finished when the process has reloaded — alert on expiry from outside so a silent renewal failure pages you at 14 and 7 days.

Do I need OCSP or CRLs for internal services?

Prefer short lifetimes over revocation. Revocation checking is inconsistent across clients and most of them soft-fail when the check is unavailable, so a compromised certificate keeps working somewhere. If you must revoke, distribute a CRL your gateways check, and accept that clients you do not control may not.

Further reading

Drills · 7

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

Classic one: after a certificate renewal, browsers load the site fine but curl fails with unable to get local issuer certificate. What is the most likely cause?

  1. curl's trust store is out of date. Possible but rare; an incomplete chain is far more common right after a renewal.
  2. The server only supports TLS 1.3 and curl does not. Modern curl supports 1.3, and the error would be a protocol failure.
  3. The server presents only the leaf certificate; browsers repair the chain from cached intermediates, curl does not. Add the intermediate(s) to the server's chain. Incomplete chains are the classic post-renewal outage for non-browser clients.
  4. The certificate is for the wrong hostname. That fails in browsers too and gives a different error.
In short

The server sends only its leaf certificate; add the intermediate certificates to the server's chain file.

Why

Roots live on the client; intermediates must come from the server. openssl s_client -showcerts shows how many certificates the server sent; if it is one, the chain file is wrong.

The common mistake

Reaching for curl -k or "update curl's CA bundle". The client is right and the server's chain file is wrong; -k hides exactly the fault every real client will hit.

Read the docs

2 Answer out loud

Explain a TLS handshake for me — TLS 1.3 — then how the client decides to trust the server, and why the load balancer needs SNI. Four to six sentences.

In short

A strong answer covers the one-round-trip handshake, the chain from leaf through intermediates to a trusted root, and SNI as how the balancer picks a certificate.

What a strong answer does
  • handshake: 1-RTT with key shares and SNI in ClientHello, encrypted certificate, forward secrecy mandatory, resumption/0-RTT caveat.
  • trust: Server sends leaf + intermediates; client builds a path to a root in its trust store, checks validity dates, name (SAN), and possibly revocation; intermediates missing is the common failure.
  • communication: Chronological handshake, precise trust logic, SNI explained as name selection before the certificate is chosen.
Why

Staff-level answers describe the 1-RTT flow, the path-building nature of trust, and SNI as a selection mechanism, each in a sentence or two.

The common mistake

Describing RSA key transport — "the client encrypts a secret with the server's public key". That is TLS 1.2 and earlier; 1.3 removed it, and the interviewer will ask which version you are describing.

3 Pick the strongest answer

Your platform still terminates most traffic on TLS 1.2. What actually changed in TLS 1.3 that you would cite for moving?

  1. SNI was removed because certificates are encrypted. SNI is still plaintext in ClientHello; Encrypted ClientHello is a separate, newer effort.
  2. Session resumption was removed for security. PSK-based resumption exists, including 0-RTT with replay caveats.
  3. It is 1.2 with faster ciphers; the handshake is unchanged. The handshake was redesigned to 1-RTT with key shares in the first flight.
  4. A full handshake takes one round trip, forward secrecy is mandatory, RSA key exchange and static Diffie-Hellman are gone, and the server certificate is encrypted. These are the headline changes from 1.2.
In short

TLS 1.3 finishes in one round trip, always gives forward secrecy, drops RSA key exchange, and encrypts the server certificate.

Why

1.3 is a simplification with consequences: fewer knobs to misconfigure, lower latency, and middleboxes that inspected certificates broke. Knowing SNI is still visible while the certificate is not is the detail interviewers listen for.

Read the docs

4 Read the output

Read this for me: what happened, and what does it say about the team's automation?

$ echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null | openssl x509 -noout -subject -issuer -dates
subject=CN = api.example.com
issuer=C = US, O = Let's Encrypt, CN = R11
notBefore=Jun  3 08:12:44 2026 GMT
notAfter=Sep  1 08:12:43 2026 GMT

$ date -u
Tue Sep  2 21:30:00 UTC 2026

$ echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>&1 | grep "Verify return"
Verify return code: 10 (certificate has expired)
  1. The intermediate R11 expired. The dates shown are the leaf's; an intermediate expiry would show on that certificate.
  2. The client's clock is wrong. A wrong client clock is possible but date -u confirms the client is right; the server's certificate is simply past notAfter.
  3. The certificate expired yesterday; renewal automation (ACME) either failed silently or the new certificate was never reloaded. Fix: renew now, reload, then add external expiry monitoring at 14 and 7 days. Return code 10 plus notAfter in the past is unambiguous; the lesson is that automation needs a monitor.
  4. Let's Encrypt revoked the certificate. Revocation gives a different verify code and does not change notAfter.
In short

The certificate expired yesterday and nobody noticed; renew and reload now, then add outside monitoring for expiry.

Why

Expiry outages are never about the certificate; they are about monitoring. The automation failed (a DNS challenge broke, a reload did not happen) and nobody was watching. External checks that page at 14 and 7 days catch every variant of this.

Read the docs

5 Find what's broken

You are reviewing this before it ships. Three lines will each produce an outage or a security finding. Which?

server {
    listen 443 ssl http2;
    server_name api.example.com;
    ssl_certificate     /etc/nginx/tls/api.example.com.crt;
    ssl_certificate_key /etc/nginx/tls/api.example.com.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    location / { proxy_pass http://api_upstream; }
}
# api.example.com.crt contains only the leaf certificate.
# Renewal: a cron job writes the new .crt/.key monthly; nginx is never reloaded.
In short

Lines 4, 6 and 11: serve the full chain, allow only TLS 1.2 and 1.3, and reload nginx after every renewal.

What's broken
  • Line 4: The certificate file contains only the leaf (per the comment); non-browser clients cannot build the chain.
  • Line 6: TLSv1 and TLSv1.1 are enabled; both are deprecated and fail compliance scans.
  • Line 11: Renewed files are written but nginx keeps serving the old certificate from memory until reloaded.
Why

Three outage classes: incomplete chain (immediate, for some clients), weak protocols (a finding today, a break tomorrow), and renewal without reload (an expiry outage on schedule). http2 and prefer_server_ciphers are fine; the proxy_pass is unrelated.

Read the docs

6 Quick recall

Quick one: you test the load balancer with openssl s_client -connect 203.0.113.10:443 and get a certificate for a completely different site. What did you leave out?

In short

You left out SNI: add -servername so the balancer knows which certificate to present.

Accepted

-servername · servername · --servername

Why

SNI — the -servername <host> flag. The hostname travels in the ClientHello and the balancer picks the certificate from it before any certificate is sent; with no SNI you get the default certificate, which is the same fault as a client library that connects by IP. With curl, --resolve host:443:IP keeps SNI honest while pinning the address.

7 Scenario: what do you do next?

Your RPC fleet requires mTLS from partner clients. At 09:00 all requests from one large partner start failing at the gateway with a TLS alert during the handshake — bad certificate on this gateway; other TLS stacks report the same fault as unknown_ca. Other partners are fine. The partner says they changed nothing. Your CA team rotated the intermediate CA certificate last night.

Step 1. What do you check first?

  1. Which side rejected and why: gateway logs for the verify error, then compare the partner's client certificate chain against the trust bundle the gateway now loads (does the bundle still contain the intermediate that signed their cert?). A verify alert sent by the server means the gateway rejected the client cert; the rotation is the prime suspect and the bundle is the evidence.
  2. Roll back the CA rotation immediately. Possibly right later, but first confirm it is the cause; rollback may break clients already issued under the new intermediate.
  3. Tell the partner to reissue their certificate. Your side changed; theirs did not. Blaming the partner delays the fix.
  4. Disable mTLS for that partner. Removes authentication during an incident instead of fixing trust.

Step 2. The new trust bundle dropped the old intermediate; the partner's client certs were issued under it and are valid for another 4 months. Mitigation?

  1. Ask the partner to trust your new CA. The failure is your gateway trusting their cert, not the reverse.
  2. Extend the outage until the partner reissues. A rotation plan that requires every client to move at once is the mistake being repeated.
  3. Accept any client certificate temporarily. That is disabling mTLS with extra steps.
  4. Add the old intermediate back to the gateway's trust bundle (both intermediates during the overlap), reload gateways, verify with the partner; plan the partner's re-issuance before the old intermediate's expiry. Cross-signing/overlap periods are how CA rotation is done without breaking issued certificates.

Step 3. Systemic fix?

  1. A CA rotation runbook with overlap windows and both intermediates in bundles, automated distribution of trust bundles, short-lived client certs (days) so re-issuance is routine, and canary partners plus alerting on mTLS verify errors per client. Makes rotation safe by design, shortens the exposure of any single certificate, and detects breakage before it is an outage.
  2. Replace mTLS with API keys. Weaker authentication to avoid learning PKI operations.
  3. Never rotate the intermediate again. Rotation is necessary; the process was the problem.
In short

Check the gateway's verify error and trust bundle first; restore the old intermediate for an overlap period, then make rotation safe with overlap windows and short-lived certs.

Why

CA rotation is the mTLS incident everyone has once: trust bundles are the shared state, and dropping an intermediate breaks every certificate issued under it. Which alert the client sees — bad certificate or unknown_ca — depends on the gateway's TLS stack, but the direction is what matters: the server rejected the client's chain. Overlap windows, automated bundle distribution, short lifetimes, and per-client verify-error alerts are the mechanisms.

Read the docs

That's the last lesson in mission 03 Pick your next mission
Drill · TLS
0:00

Loading…