map / networking / tls

Networking · principle 4 of 6

TLS

TLS adds a handshake on top of TCP (one round trip in TLS 1.3, two in 1.2) before any application data flows.

01 · Why it’s true

TLS lets a client check it’s talking to the right server, then encrypts the traffic. The server presents a certificate, signed by a certificate authority the client already trusts, that ties a public key to the hostname.

During the handshake the two sides agree on encryption keys. TLS 1.3 needs one round trip; TLS 1.2 needs two. Resumed sessions skip some of the work, and TLS 1.3’s optional 0-RTT mode lets a client send data immediately — at the cost that this early data can be replayed by an attacker.

02 · Picture it

Clientbrowser or API clientServerhas the certificate andprivate keyTLS 1.3: 1 round trip on top of TCP1ClientHello + key share2ServerHello, certificate, Finished3check chain, expiry, hostname4Finished + encrypted request5encrypted responserequestresponsestep inside one actorTLS 1.2 needs one more round trip. Step 3 is where certificate errors come from: anexpired cert, the wrong hostname, or a missing intermediate.
WHO’S INVOLVEDClientbrowser or API clientServerhas the certificate and private keyTLS 1.3: 1 round trip on top of TCP1Client → ServerClientHello + key share2Server → ClientServerHello, certificate, Finished3Clientcheck chain, expiry, hostname4Client → ServerFinished + encrypted request5Server → Clientencrypted responserequestresponsestep inside one actorTLS 1.2 needs one more round trip.Step 3 is where certificate errorscome from: an expired cert, the wronghostname, or a missing intermediate.
Prove identity, agree on keys, then everything is encrypted.

03 · In the interview

  • Debugging certificate errors: expired, wrong hostname, or a missing intermediate certificate.
  • Explaining where TLS terminates (load balancer, proxy, or app) and who can see plaintext.
  • Treating certificate expiry as an operational risk to automate and monitor.

04 · Practice question

“Some API clients started failing with certificate errors, but browsers work fine. What do you check?”

A strong answer covers

  1. Read the exact error: expired, hostname mismatch, or unknown issuer.
  2. Unknown issuer on some clients only often means the server isn’t sending the full chain; browsers can often fill in a missing intermediate, many libraries can’t.
  3. Inspect what the server actually sends with openssl s_client -connect host:443 -servername host -showcerts.
  4. Check expiry for every certificate in the chain, and whether failing clients have an outdated trust store.
  5. Afterwards: automate renewal and alert on expiry well in advance.