<!-- Markdown version for AI agents and readers. Canonical: https://pratikdhanave.com/blog/posts/crypto-06-tls.html -->

# TLS: Where It All Comes Together

*TLS is the protocol securing nearly every connection you make, and it's not a single cryptographic trick — it's the whole toolkit orchestrated into one handshake. Key exchange, certificates, signatures, and authenticated encryption each solve one sub-problem, and TLS composes them so that two parties who've never met can establish a private, tamper-proof, authenticated channel over a hostile network. Understanding the handshake is understanding how every earlier piece fits.*

Everything so far — symmetric encryption, hashing/MACs, public-key crypto, signatures, and PKI — comes together in **TLS** (Transport Layer Security), the protocol behind HTTPS and secure communication generally. TLS is the canonical example of applied cryptography as a *system*: no single primitive makes a connection secure; the *composition* does. This post walks through what TLS provides, how the handshake works, and why its design choices (forward secrecy, AEAD, TLS 1.3's streamlining) matter.

## What TLS provides

TLS sits between the application and the transport (TCP), turning an insecure connection into a secure one that provides all the guarantees from the first post:

- **Confidentiality** — everything after the handshake is encrypted with symmetric AEAD, so eavesdroppers on the network see only ciphertext.
- **Integrity** — the AEAD authentication tags ensure any tampering with the data is detected and rejected.
- **Authentication** — via certificates and PKI, the client verifies the server's identity (and optionally the server verifies the client), so you know *who* you're talking to, not just that the channel is encrypted.

Crucially, TLS delivers these to two parties who share no prior secret, over a network an attacker may control. It does so by orchestrating the primitives: public-key key exchange to establish a shared secret, certificates/signatures to authenticate identity, and symmetric AEAD to protect the bulk data. TLS is the hybrid model (from the public-key post) made concrete, plus PKI for identity. The handshake is where the orchestration happens.

## The handshake

The **TLS handshake** is the negotiation at the start of a connection that authenticates the parties and establishes the shared symmetric keys. Conceptually (TLS 1.3, simplified):

```text
TLS 1.3 handshake (simplified):
   Client → Server:  "hello" + supported ciphers + client's ephemeral DH public key
   Server → Client:  "hello" + chosen cipher + server's ephemeral DH public key
                      + certificate (its public key, CA-signed)
                      + signature (proving it holds the certificate's private key)
   Both:             derive the same shared secret from the DH exchange
                      → derive symmetric keys → switch to encrypted AEAD traffic
   ... all application data now encrypted with the symmetric keys ...
```

Walking through what each step accomplishes, using the earlier posts:

- **Negotiation.** Client and server agree on a **cipher suite** — which key-exchange, signature, and AEAD algorithms to use — picking the strongest both support. This lets TLS evolve (drop weak algorithms) while staying interoperable.
- **Key exchange.** Both send *ephemeral* Diffie-Hellman public keys (ECDHE) and each derives the *same* shared secret, which an eavesdropper can't compute (the public-key post). From this secret, both derive the symmetric session keys. This solves key distribution: a shared key established over the open network.
- **Authentication.** The server sends its **certificate** (its public key, signed by a CA) and a **signature** proving it holds the corresponding private key. The client validates the certificate chain to a trusted root (the PKI post) and checks the signature — confirming it's really talking to the legitimate server, defeating the man-in-the-middle. (Mutual TLS adds client-certificate authentication the same way.)
- **Switch to symmetric.** Once keys are established and identity verified, both switch to fast symmetric **AEAD** encryption (AES-GCM or ChaCha20-Poly1305) for all application data. The expensive public-key work happened once; the conversation runs on cheap symmetric crypto.

So the handshake is every primitive in the series, in sequence: negotiate → key-exchange (asymmetric) → authenticate (certificates + signatures) → encrypt (symmetric AEAD). That composition is what makes a secure channel from a hostile network.

## Forward secrecy and why ephemeral keys matter

A design choice worth dwelling on: TLS 1.3 *mandates* **ephemeral** Diffie-Hellman (ECDHE) — a fresh key pair for every session — which provides **forward secrecy**:

- **What it guarantees.** Each session's keys are derived from ephemeral values that exist only for that session and are then discarded. So even if the server's long-term private key is later compromised, an attacker *cannot* decrypt past recorded sessions — the ephemeral secrets that protected them are gone. Past traffic stays safe even after a future key compromise.
- **Why it matters.** Without forward secrecy (as in older key-exchange schemes where the session key was encrypted with the server's long-term key), an attacker who records encrypted traffic today and steals the private key years later could decrypt *everything* retroactively. Forward secrecy defeats this "harvest now, decrypt later" threat for past sessions. It's a major security improvement and a big reason TLS 1.3 requires ephemeral key exchange.

Forward secrecy is a great example of how protocol *design* — not just algorithm choice — determines real security. The same Diffie-Hellman, used ephemerally, upgrades the guarantee from "secure unless the key leaks" to "past sessions secure even if the key leaks later."

## TLS 1.3: simpler and safer

TLS has evolved, and **TLS 1.3** (the current version) is a significant improvement over TLS 1.2, worth knowing as the modern baseline:

- **Removed the dangerous options.** TLS 1.3 stripped out old, weak, and misuse-prone algorithms and modes (static RSA key exchange, weak ciphers, unauthenticated modes), leaving only strong AEAD ciphers and forward-secret key exchange. Fewer options means fewer ways to misconfigure insecurely — misuse-resistance at the protocol level.
- **Faster handshake.** TLS 1.3 reduced the handshake to essentially one round trip (1-RTT), with an optional 0-RTT resumption for repeat connections — so secure connections are established faster, removing a historical performance excuse for not using HTTPS.
- **Forward secrecy by default.** As above, ephemeral key exchange is mandatory, so every TLS 1.3 connection has forward secrecy — no longer an optional extra.

The practical takeaway: **use TLS 1.3** (or 1.2 at minimum with strong settings), and disable old versions (SSL, TLS 1.0/1.1) which have known weaknesses. Modern TLS is both safer and faster, and its design reflects the whole series' lessons: prefer misuse-resistant defaults, mandate forward secrecy, drop weak options.

## What this means for engineers

You rarely implement TLS, but you configure, deploy, and depend on it constantly — and understanding it guides real decisions:

- **Terminate TLS correctly.** Use well-configured servers/load balancers, modern TLS versions, strong cipher suites, and valid certificates. Tools and defaults (and guides like Mozilla's SSL configuration recommendations) help you avoid weak configurations — you don't hand-pick ciphers blindly.
- **Manage certificates operationally.** Certificates expire and must be renewed (automate with ACME/Let's Encrypt) and their private keys protected — expired certs are a classic outage, leaked private keys a classic breach. This is where TLS meets key management (next post).
- **Understand the trust boundary.** TLS secures data *in transit* between endpoints. It doesn't protect data at rest, doesn't help if an endpoint is compromised, and (with TLS termination at a load balancer) traffic may be plaintext *inside* your network unless you also encrypt there. Knowing exactly what TLS does and doesn't cover prevents false confidence.
- **Recognize it as the series in one protocol.** When you see the padlock, you're seeing key exchange, certificates, signatures, PKI, and AEAD working together. Understanding TLS is understanding how applied cryptography composes into a real secure system.

TLS orchestrates every primitive in this series — negotiated cipher suites, ephemeral key exchange for a shared secret with forward secrecy, certificates and signatures for authentication, and AEAD for the encrypted conversation — into a secure channel over a hostile network. It's applied cryptography as a system. Next: key management, the operational discipline that everything (TLS certificates included) ultimately depends on.

## Key takeaways

- TLS turns an insecure connection into one with confidentiality (AEAD encryption), integrity (AEAD tags), and authentication (certificates/PKI) between parties who share no prior secret over a hostile network — it's the hybrid model plus PKI made concrete.
- The handshake composes every primitive in sequence: negotiate a cipher suite, do ephemeral Diffie-Hellman (ECDHE) key exchange to derive a shared secret, authenticate via the server's CA-signed certificate and a signature (validated up the chain to a trusted root, defeating MITM), then switch to fast symmetric AEAD for all application data.
- Forward secrecy — from mandatory ephemeral (per-session) key exchange in TLS 1.3 — means a later compromise of the server's long-term private key can't decrypt past recorded sessions, defeating "harvest now, decrypt later"; it's a protocol-design win, not just an algorithm choice.
- TLS 1.3 is the modern baseline: it removed weak/misuse-prone options (leaving strong AEAD + forward-secret exchange), cut the handshake to ~1-RTT (faster), and made forward secrecy default — use TLS 1.3 (1.2 minimum) and disable SSL/TLS 1.0/1.1.
- For engineers: configure TLS with modern versions/strong ciphers/valid certs (using vetted config guidance), automate certificate renewal and protect private keys, and understand TLS's boundary — it protects data *in transit* between endpoints only, not at rest or inside a network past TLS termination.

## Further reading

- [RFC 8446 — The TLS 1.3 protocol specification](https://www.rfc-editor.org/rfc/rfc8446)
- [Digital signatures and PKI (previous post)](/blog/posts/crypto-05-signatures-and-pki.html)
- [Computer Networking for Backend Engineers — where TLS sits in the stack](/blog/series/computer-networking-for-backend-engineers/)

---

Author: Pratik Dhanave (https://pratikdhanave.com) | Published: 2026-08-16
Canonical: https://pratikdhanave.com/blog/posts/crypto-06-tls.html
Attribution: please link the canonical URL when citing or quoting this post.
