Heads up: posts on this site are drafted by Claude and fact-checked by Codex. Both can still get things wrong — read with care and verify anything load-bearing before relying on it.
why → how

What is TLS?

TCP gives you a reliable byte stream that any router along the path can read and modify. TLS is the layer that wraps that stream so you get confidentiality, integrity, and proof of who's on the other end.

Networking intro Apr 30, 2026 · updated Aug 25, 2026 · 9 min read

On this page

The picture version

Five pictures for a reader who has never wondered what the padlock means, following one action: logging into your email over carriage Wi-Fi.

1 · The problem

Your password crosses a dozen machines you’ll never see.

your laptop hunter2 access pointtrain uplinkyour ISProuters mail server every one of these sees the bytes exactly as you typed them TCP moves the bytes reliably. It does not hide them. and any of these hops could change them mid-flight without you or the server noticing
TCP’s design predates the assumption that the network is hostile, and nothing was retrofitted into it. TLS is a separate layer wrapped around that stream, buying three things at once: only the endpoints can read the bytes, tampering is detected rather than delivered, and you get evidence about who is on the other end.

2 · The first move

Build a shared secret out loud, in a full carriage.

your laptop the mail server my public half and mine every hop on the path hears both of these combine combine the same shared secret on both ends, never sent Both halves were public. The secret never crossed the carriage. and it is generated fresh per connection, so stealing the server’s long-term key in 2030 won’t decrypt today’s traffic
An eavesdropper who captured both public halves still cannot compute the result — that asymmetry is the whole point of the maths. Throwing the halves away afterwards is what buys forward secrecy, and it is why TLS 1.3 dropped the older scheme where the key was simply encrypted to the server’s long-term key.

3 · The half that isn’t encryption

A secret with somebody is not a secret with the right somebody.

you the ceiling access point mail server one exchange a second exchange two perfectly encrypted connections, and it reads everything so in the same flight, the server also proves who it is certificate chain signatures your laptop can follow up to an authority already in its root store transcript signature signed with that certificate’s private key — the part a copied certificate cannot produce Key agreement gives you a secret with somebody. The certificate is what makes that somebody your mail server.
Anyone can run the exchange from scene 2 — that is exactly why it isn’t enough on its own. Copying a certificate doesn’t help an impostor, because the signature has to be computed over this handshake with a private key the impostor doesn’t hold.

4 · The cheap half

Every byte after that rides in a sealed, tagged record.

after the handshake, every byte goes through the cheap half ciphertextciphertextciphertextciphertextciphertext each record carries a tag (the accent strip) computed over its own contents flip any bit in transit on the wire the tag check fails, and the record is rejected Confidentiality and integrity out of one primitive. public-key maths is far too slow for bulk data, so it runs once, briefly, only to bootstrap this
This is the part actually carrying your login, and every message your client fetches afterwards. The expensive handshake happens once per connection; the cheap symmetric half runs for everything else — which is the whole reason the protocol is split in two.

5 · Keep this card

The whole thing on one index card.

TLS = a handshake, run once per connection + an encrypted record stream for every byte after ∴ the handshake does two separate jobs… … and only one of them is encryption drop the second job and the access point on the ceiling gets a perfectly encrypted copy of your password
Picture to keep: two strangers in a crowded carriage building a shared combination out loud — everyone hears both halves and still can’t work out the combination — then locking every later message in a box only that combination opens. Where it breaks: nothing in that picture stops one of the “strangers” from being an impostor, which is precisely the job the certificate does and the key agreement doesn’t.

Why it exists

You’re on the train, logging into your email over the carriage Wi-Fi. The bytes of your password leave your laptop, pass through an access point bolted to the ceiling, through the train operator’s uplink, through whichever ISP carries it, and through a handful of routers you’ll never see. Nothing about TCP stops any intermediary on that path from reading those bytes, or changing them. That login on the train is the example this post follows.

TCP gives you a reliable, ordered byte stream between two computers. What it does not give you is any privacy. Any router, ISP, or coffee-shop access point along the path can read those bytes in the clear, and could modify them mid-flight. TCP’s design predates the assumption that the network is hostile, and nothing was retrofitted into it.

TLS — Transport Layer Security — wraps that stream and gives it three properties TCP doesn’t:

  1. Confidentiality — only the two endpoints can read the bytes.
  2. Integrity — a tampered byte is detected, not silently delivered.
  3. Authentication — the client gets cryptographic evidence that the server is the one it intended to reach.

The SSL name you still hear (“SSL certificates”) is a vestige of the Netscape-era predecessor; every version of SSL is formally deprecated. What ships today is TLS, with TLS 1.3 (RFC 8446, 2018) the current version and TLS 1.2 (RFC 5246, 2008) still present for compatibility with older clients.

Why it matters now

A large share of the network calls modern infrastructure makes have TLS underneath:

The browser padlock is just the visible tip. TLS is the load-bearing encryption layer under most of the working internet.

The short answer

TLS = handshake (key agreement + server cert verification) + encrypted record stream with tamper detection

Picture to keep: two strangers in a crowded carriage building a shared combination out loud — everyone hears both halves and still can’t work out the combination — then locking every later message in a box only that combination opens. Where the picture breaks: nothing in it stops one of the “strangers” from being an impostor, which is precisely the job the certificate does and the key agreement doesn’t.

Two phases, two jobs. The handshake is expensive public-key crypto, run once per connection: both sides agree on a fresh shared secret, and the client checks the server’s certificate. The record layer is cheap symmetric encryption that runs for every byte after that. The split exists because public-key math is too slow for bulk data — so it’s used briefly, just to bootstrap a symmetric key that does the real work.

How it works

Phase 1: the handshake

Each step below is forced by the failure of the step before it.

Naive attempt: encrypt with a shared password. Fine for two people who met beforehand. Useless for your laptop and a mail server that have never exchanged anything, over a carriage access point that reads everything. The two ends have to invent a shared secret in full view of the train.

Fix: agree on a secret in public. The client opens with a ClientHello — supported TLS versions, cipher suites, and a key share, its half of an ECDHE exchange. The server answers with ServerHello and its own half. Each side then combines its private share with the other’s public share; the Diffie–Hellman math means both land on the same secret, while an eavesdropper who saw both public halves still cannot compute it. That’s key agreement, and the secret is then run through HKDF to produce the actual record-layer keys.

But key agreement authenticates nobody. The access point on the ceiling can run that same exchange with you, and a second one with the real mail server, and sit in the middle reading plaintext. Fix: in the same flight the server sends its certificate chain and signs the handshake transcript with the certificate’s private key. The client walks the chain up to a trusted CA in its root store — signatures, dates, hostname — and checks that transcript signature, which is the part a copied certificate can’t produce. The chain-of-trust details get their own deep dive in HTTPS certificates.

sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: ClientHello — versions, ciphers, my key share
    S->>C: ServerHello — my key share
    S->>C: Certificate + signature over the transcript
    Note over C,S: both derive the same secret; client verifies chain
    C->>S: application data (1 RTT after the first packet)

But one long-term key is a single point of retroactive failure. If the symmetric key were simply encrypted to the server’s long-term key — the old static-RSA approach — anyone who recorded today’s traffic and stole that key in 2030 could decrypt all of it. Fix: make the key share fresh per connection (the E in ECDHE, ephemeral) and throw it away afterwards. That property is forward secrecy, and it’s why TLS 1.3 dropped static RSA key transport entirely.

And even with secrecy and authentication solved, setup still costs round trips before your password moves. TLS 1.2 needed two. TLS 1.3 gets a fresh connection down to 1-RTT by having the client guess a key share in its very first message, and a resumed connection to 0-RTT, where application bytes ride along with the ClientHello. That round-trip win is a large part of why TLS 1.3 — and QUIC, which folds the handshake into the transport — feel snappier on a high-latency link like a train.

Phase 2: the record layer

After the handshake, the rest is simpler. Application bytes get chopped into records, each encrypted with an AEAD construction (AES-GCM and ChaCha20-Poly1305 are the two you’ll see) and shipped over the underlying TCP connection. AEAD gives you confidentiality and integrity in one primitive: flip any bit in transit and the receiver’s tag check fails, and the record is rejected. The record layer is what’s actually moving your login — and every mail your client fetches afterwards — once the connection is up.

Show the seams

You started with TLS = handshake + encrypted record stream. What did the train ride add? — + the handshake does two separate jobs, and only one of them is encryption. Key agreement gives you a secret with somebody; the certificate and the transcript signature are what make that somebody your mail server. Drop the second job and the access point on the ceiling gets a perfectly encrypted copy of your password.

Going deeper