The Secret Handshake
HTTP sends data as plain text. Anyone on the network path between you and the server — your ISP, a coffee shop router, a government firewall — can read every byte. To fix this, we wrap HTTP inside an encrypted tunnel called TLS (Transport Layer Security). The combination is HTTPS (HTTP Secure).
TLS provides three guarantees:
1. Confidentiality: The data is encrypted. Eavesdroppers see only ciphertext.
2. Integrity: The data cannot be tampered with in transit without detection.
3. Authentication: The server proves its identity via a certificate signed by a trusted Certificate Authority (CA). You know you're talking to the real google.com, not an impersonator.
The TLS Handshake
Before any HTTP data flows, the client and server must negotiate encryption keys. This negotiation is the TLS handshake.
In TLS 1.2, the handshake required two full round-trips before data could flow:
Client → Server: "Client Hello" (supported cipher suites, TLS version)
Server → Client: "Server Hello" + Certificate + "Server Hello Done"
Client → Server: Key exchange data + "Change Cipher Spec" + "Finished"
Server → Client: "Change Cipher Spec" + "Finished"
[Now HTTP data can flow — after 2 round-trips]
In TLS 1.3, the handshake was redesigned to require only one round-trip:
Client → Server: "Client Hello" (supported cipher suites + key share guess)
Server → Client: "Server Hello" + Certificate + "Finished" + encrypted extensions
[Now HTTP data can flow — after 1 round-trip]
The client makes an educated guess about which key exchange algorithm the server will choose and sends its key share upfront. If the guess is right (it usually is, since TLS 1.3 reduced the supported cipher suites to a small, modern set), the server can complete the handshake in one message. TLS 1.3 also removed support for weak, legacy cryptographic algorithms that TLS 1.2 still allowed.
Critical TLS Extensions
During the "Client Hello," the client sends two extensions that are essential for modern infrastructure:
-
SNI (Server Name Indication): A single IP address can host thousands of websites (virtual hosting). Without SNI, the server wouldn't know which certificate to present. SNI solves this: the client includes the hostname it's trying to reach in the Client Hello, before encryption is established. Note: because SNI is sent in plaintext, it reveals which hostname you're connecting to — even over HTTPS. This is why ESNI/ECH (Encrypted Client Hello) is being developed.
-
ALPN (Application-Layer Protocol Negotiation): The client advertises which application protocols it supports (e.g.,
h2for HTTP/2,http/1.1). The server picks one and confirms it in the handshake. This means by the time the TLS handshake completes, both sides have already agreed on which HTTP version to use — no additional negotiation needed.
Key Point: TLS 1.3 is not just faster — it is more secure. It eliminated support for weak cipher suites (RC4, DES, 3DES), removed RSA key exchange (which doesn't provide forward secrecy), and made forward secrecy mandatory. Forward secrecy means that even if an attacker records your encrypted traffic today and later steals your server's private key, they still cannot decrypt the old traffic — because the session keys were ephemeral and never stored.