What it is
HTTPS is HTTP sent inside a TLS (Transport Layer Security) connection. TLS sits between TCP (or QUIC) and the application and provides three guarantees: confidentiality (an observer cannot read the bytes), integrity (changes are detected) and authentication (the client knows which server it is talking to; optionally the server also authenticates the client, called mutual TLS). TLS 1.3 (RFC 8446) is the current version; TLS 1.2 is still widely supported, older versions are deprecated.
Why it exists
Traffic crosses networks you do not control: Wi-Fi hotspots, ISPs, transit providers. Without TLS any of them can read passwords and cookies or inject content into pages. Browsers mark plain HTTP as insecure, only speak HTTP/2 and HTTP/3 over TLS, and restrict many features (service workers, geolocation, camera) to secure contexts.
How it works
Handshake (TLS 1.3, full). After the TCP handshake:
- The client sends ClientHello: supported versions and cipher suites, the server name (SNI), application protocols (ALPN, e.g.
h2) and a key share for its preferred key-exchange group. - The server replies with ServerHello (its key share). From here on everything is encrypted: EncryptedExtensions, Certificate, CertificateVerify (a signature over the handshake with the certificate’s private key) and Finished.
- The client verifies the certificate, sends its Finished, and can send application data in the same flight.
That is one round trip before the first request, versus two for TLS 1.2. If the server does not support the client’s guessed group it answers with HelloRetryRequest, costing an extra round trip.
Key exchange. The key shares are ephemeral (EC)DHE values, so each connection derives fresh keys that are discarded afterwards: forward secrecy. Since 2024–2025 major browsers and CDNs use the hybrid group X25519MLKEM768, which combines X25519 with the post-quantum ML-KEM (FIPS 203), protecting recorded traffic against future quantum attacks on the key exchange. Bulk data is then encrypted with an AEAD cipher (AES-GCM or ChaCha20-Poly1305).
Certificate verification. The server sends its leaf certificate plus intermediates. The client checks that each certificate is signed by the next, that the chain ends at a root in its local trust store, that the leaf’s Subject Alternative Name matches the hostname, that it is within its validity period and that it carries Certificate Transparency proofs. CertificateVerify proves the server holds the private key. Revocation is increasingly handled by lists pushed to clients ahead of time (Firefox’s CRLite, Chrome’s CRLSets); live OCSP is being retired (Let’s Encrypt shut down its OCSP service in 2025). The CA/Browser Forum’s ballot SC-081 reduces the maximum certificate lifetime to 200 days from March 2026, 100 days from March 2027 and 47 days from March 2029, which makes automated renewal (ACME) mandatory in practice.
Resumption. After a handshake the server can issue session tickets. A later ClientHello presents one as a pre-shared key (PSK), normally together with a fresh key share (psk_dhe_ke) to keep forward secrecy. The server skips sending and signing the certificate. Still one round trip, but less CPU and fewer bytes.
0-RTT early data. With a PSK, the client may send application data in its first flight, encrypted with a key derived only from the PSK. The server can answer immediately, so the first response arrives after one round trip in total. Early data has no protection against replay: an attacker who records the flight can resend it. Servers therefore limit it to idempotent requests, may keep single-use tickets or replay caches (hard across many servers), and TLS terminators forward early requests with Early-Data: 1 so the origin can reply 425 Too Early (RFC 8470), after which the client retries once the handshake completes.
What stays visible. IP addresses, timing and sizes, and — unless Encrypted Client Hello (ECH) is used — the SNI hostname. DNS lookups are visible too unless DNS is encrypted.
When to use it
Always, for anything that crosses a network you do not fully control, and increasingly inside data centres as well (zero-trust networking, service meshes with mTLS). Use HSTS so browsers never try plain HTTP for your domain.
When not to
There is hardly a case for plaintext on the public internet. Inside a trusted, isolated network segment, some teams still terminate at the edge and run plain HTTP internally for simplicity and debuggability; that is a risk decision, not a performance necessity. 0-RTT specifically should stay off for endpoints with side effects unless replay is handled.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Terminate TLS on each app server | End-to-end encryption, simple balancer | Crypto on app CPUs, private keys on every server, renewals everywhere |
| Terminate at load balancer / edge | Central certificates, L7 routing, app capacity freed | Plaintext inside unless re-encrypted; the balancer holds the keys |
| Re-encrypt to backends (mTLS) | Encryption and service identity inside | Internal PKI to run; small CPU cost on pooled connections |
| TLS passthrough (route by SNI) | End-to-end encryption, keys only on backends | No HTTP-level routing, retries or header logic at the balancer |
| Enable 0-RTT | One round trip less for repeat visitors | Replay risk; must restrict to idempotent requests |
Alternatives
- QUIC / HTTP/3 integrates TLS 1.3 into the transport: transport and crypto handshake share one round trip (see the HTTP/2 and HTTP/3 lesson).
- Mutual TLS instead of bearer tokens for service-to-service identity.
- Application-layer encryption (e.g. encrypting fields end to end) when intermediaries that terminate TLS must not see the data.
Failure modes
- Expired certificates remain one of the most common causes of outages; shorter lifetimes make manual renewal untenable.
- Incomplete chains: a server that omits the intermediate works in browsers that cached it and fails elsewhere.
- Clock skew on clients makes valid certificates look expired or not yet valid.
- Handshake storms: after a balancer restart or failover, every client reconnects and performs full handshakes at once; session tickets that survive restarts (shared ticket keys) soften this.
- 0-RTT replay of non-idempotent requests.
- Ticket key management: session-ticket encryption keys that are never rotated weaken forward secrecy for resumed sessions.
In production
Automate issuance and renewal with ACME, alert on certificate expiry well ahead, serve complete chains, and prefer ECDSA certificates (smaller and faster to verify than RSA) where clients allow. Terminate TLS at the edge or balancer for public traffic, re-encrypt internally if your threat model includes the internal network, and keep backend connections pooled. Rotate session-ticket keys and share them across the fleet behind one name. Enable HSTS (and consider preloading). Allow 0-RTT only for idempotent routes and honour Early-Data / 425 at the origin.
Common misconceptions
- “HTTPS hides which site I visit.” The IP address and usually the SNI are visible; only ECH and encrypted DNS hide the hostname.
- “TLS is slow.” TLS 1.3 adds one round trip on a new connection and almost nothing on a reused one; symmetric encryption is cheap on modern CPUs.
- “The certificate encrypts the traffic.” The certificate key only signs; traffic keys come from the ephemeral key exchange.
- “0-RTT is a free speed-up.” Early data can be replayed.
- “The browser asks the CA on every connection.” Verification is local against the trust store.
Interview angle
Expect to explain where TLS terminates in your design and why: at the CDN or load balancer for public traffic, with re-encryption or mTLS internally if required. Be ready to count round trips (TCP + TLS 1.3 + request = 3 RTT on a cold connection; QUIC saves one), to explain certificate verification in two sentences, and to point out that 0-RTT data is replayable. Mentioning certificate automation, shrinking lifetimes and handshake storms after failover shows operational experience.
Model assumptions
Steps 1–8 are a scripted illustration, not a simulation: every packet is placed by hand to show the order of messages. One-way latency is 10 ms between browser and Wi-Fi and 10 ms between Wi-Fi and the site (a 40 ms round trip); the TCP handshake before TLS is not shown, and multiple TLS records in one flight are drawn as a single packet. The trust-store check is drawn as a 2 ms local lookup. Steps 9–11 are simulated: two app servers with 4 workers each and a lognormal service time (cv 0.5) of 20 ms of application work; terminating TLS on the app servers adds an illustrative 8 ms per request (an average over full handshakes for new connections and record encryption), re-encryption on pooled connections adds 1 ms. The balancer’s crypto work is modelled only as 1 ms of extra latency, not as limited capacity. Arrivals are Poisson. Numbers show behaviour and orders of magnitude, not benchmarks.