Every byte between a client and your server passes through routers you don't control. Without encryption, anyone on the path reads passwords, session tokens, the works. TLS encrypts it all — but also adds latency (the handshake) and cost (certificate management). Getting this right matters; getting it wrong is a CVE.
TLS + HTTP = HTTPS. In 2025 there is no reason to serve anything over plain HTTP. Let's Encrypt made certs free. Let's understand what's actually happening under the lock icon.
02
What TLS provides
Confidentiality — encrypted in transit.
Integrity — tampered bytes detected (via HMAC).
Authentication — you're actually talking to api.example.com, not a man-in-the-middle pretending to be (via the certificate chain).
Mutual TLS (mTLS) adds the reverse: the server verifies the client too. Used heavily in service-to-service auth inside trusted networks.
03
The TLS 1.3 handshake
One round-trip in TLS 1.3 (vs two in 1.2). Standard procedure for a new connection:
ClientHello — client sends supported cipher suites, a random number, and its ephemeral public key.
ServerHello — server picks a cipher, sends its certificate, its own random, its ephemeral public key, and a MAC over everything.
Both sides derive a shared secret from the two ephemeral keys (Diffie-Hellman). Subsequent data is encrypted with AES-GCM or ChaCha20-Poly1305 using the derived key.
Total: one round-trip. For a repeat visitor with session resumption, zero round-trips to start sending data (0-RTT mode).
TLS 1.3 HandshakeMermaid
sequenceDiagram
participant C as Client
participant S as Server
C->>S: ClientHello - cipher suites - client random - DH public key
S->>C: ServerHello + Certificate + Finished - chosen cipher - server random - DH public key - signed cert chain
Note over C,S: Both derive shared secret via DH
C->>S: Finished (encrypted) + HTTP request
S-->>C: HTTP response (encrypted)
04
Certificate chain
Your server presents a certificate signed by an intermediate CA, which is signed by a root CA. Browsers ship with the root CAs' public keys baked in; the chain verifies up to that trust anchor.
When your cert is about to expire, your deploy has to refresh it. Let's Encrypt issues 90-day certs; their ACME protocol automates renewal via bots like certbot. Always automate renewal — manual means you'll forget once, and the outage is a 2am incident.
SNI (Server Name Indication): since many sites share one IP, the client sends the hostname in the ClientHello so the server knows which cert to present. Before SNI, you needed one IP per cert; today, Cloudflare serves 10M+ sites from the same IPs.
05
Where TLS terminates
At the edge / load balancer
Terminate at the LB; plain HTTP internally
The LB or CDN handles TLS. Internal traffic is plain HTTP over a private network. Simpler; faster internally. Required for header-based routing (LB can't route if it can't read the request).
End-to-end TLS
Encrypted all the way to the app
TLS terminates at the app or at each service. Required in zero-trust architectures. Adds CPU cost and makes some LB features (path-based routing of encrypted traffic) harder.
06
Deep dive — 0-RTT and the replay risk
TLS 1.3's 0-RTT mode lets a returning client send application data in the first packet, using a pre-shared key from a previous session. The handshake takes zero round-trips. Amazing for mobile networks with 200ms+ RTT.
The trap: 0-RTT data is replayable. An attacker who recorded the original request can replay it to the server, which has no way to distinguish "fresh request" from "replay." For idempotent GETs, harmless. For POST that charges a card — catastrophic.
Mitigation: restrict 0-RTT to safe methods (GET, HEAD) at the LB level. All mainstream LB stacks offer this as a config flag. Use 0-RTT for static content, fall back to 1-RTT for mutations.
07
Real-world
Let's Encrypt
Free certs + ACME automation
Revolutionized cert management. Default for most startups and indie projects. 90-day certs, auto-renewed.
Cloudflare
Terminates TLS at 300 PoPs
Universal SSL free. Your origin only speaks HTTPS to Cloudflare; CF speaks HTTPS to the world.
mTLS in service mesh
Istio, Linkerd
Inside Kubernetes: every pod has a cert; every service call is mTLS. Zero-trust networking without app changes.
AWS ACM
Managed certs for AWS services
Issues and auto-renews certs for ALB, CloudFront, API Gateway. No manual rotation.
08
Used in problems
Payment gateway requires end-to-end TLS — PCI compliance mandates it. WhatsApp uses TLS for client-server + Signal Protocol for end-to-end encryption. Every public-facing API problem uses TLS by default.