How SSL/TLS works · Lesson 3 of 8 · 4 min read
The TLS handshake step by step
TLS 1.2 (two round trips)
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Total before the first HTTP request on a fresh connection: 1 RTT for TCP + 2 RTTs for TLS 1.2 = 3 RTTs. Between Chennai and a US-East server (~230 ms RTT) that's ~700 ms before the request even leaves.
TLS 1.3 (one round trip)
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
The client sends its key share in the first message, so keys are ready after one round trip. Improvements over 1.2:
- 1-RTT handshake; 0-RTT resumption for returning clients (data in the first flight). 0-RTT data can be replayed by an attacker, so only allow it for idempotent requests (GET), which CDNs enforce.
- Removed weak and legacy options: RSA key exchange, static DH, CBC-mode ciphers, RC4, SHA-1, compression, renegotiation.
- Always forward secret; only five AEAD cipher suites (e.g.
TLS_AES_128_GCM_SHA256,TLS_CHACHA20_POLY1305_SHA256). - More of the handshake is encrypted (the certificate is no longer visible to passive observers).
What the client verifies
- The chain leads to a trusted root and every signature is valid.
- The certificate is within its validity dates (clock skew on the client breaks this!).
- The hostname matches a SAN (exact or one-level wildcard).
- Key usage permits server authentication; not revoked (where checked).
- The server proved possession of the private key (CertificateVerify / signed key exchange).
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
SNI and ALPN
- SNI (Server Name Indication) — the client puts the hostname in the ClientHello so a server/load balancer hosting many domains on one IP can choose the right certificate. Clients that don't send SNI (old Java, some
opensslcommands without-servername) get the default certificate → name mismatch errors. ALBs support multiple certificates per listener selected by SNI. - ALPN — negotiates the application protocol (
h2for HTTP/2,http/1.1) inside the handshake.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Session resumption
Full handshakes cost CPU (asymmetric crypto) and round trips. Session tickets / PSKs let a returning client resume with abbreviated handshakes — an important optimisation for load balancers handling many short connections. ECDSA certificates are also much cheaper to sign with than RSA 2048/4096, reducing server CPU.