Skip to content

Technology

What Happens During a TLS Handshake

How a browser and a server with no prior relationship agree on encryption, authenticate each other, and start talking securely.

3 min read

When a browser opens https://example.com, the two ends share no secrets and have never met, yet within a fraction of a second they are exchanging encrypted data. The TLS handshake is the negotiation that makes this possible: it establishes what cryptography to use, proves the server is who it claims to be, and agrees on session keys — all over an insecure channel.

The handshake has three jobs: negotiate (agree on a TLS version and cipher suite), authenticate (verify the server’s identity via its certificate), and establish keys (derive shared session keys that only the two ends know). In TLS 1.3, the current version, this takes one round trip; the older TLS 1.2 took two.

In TLS 1.3, the exchange is roughly:

  1. ClientHello. The client sends the TLS versions and cipher suites it supports, a random value, and — the key TLS 1.3 optimisation — its key-share: a public value for an ephemeral Diffie–Hellman exchange, sent speculatively before knowing which group the server will pick.
  2. ServerHello. The server picks the version and cipher suite, sends its own key-share and random value. At this point both sides can compute the same shared secret, even though an eavesdropper who saw both public values cannot.
  3. Certificate. The server sends its X.509 certificate chain and a digital signature proving it holds the certificate’s private key. The client verifies the chain against its store of trusted certificate authorities and checks that the certificate is valid for the requested hostname.
  4. Finished. Both sides exchange a message authentication code over the handshake transcript, confirming nothing was tampered with. Encrypted application data can now flow.

The keys are ephemeral: fresh Diffie–Hellman values are generated per connection and discarded afterwards, giving forward secrecy — even if the server’s long-term private key is later stolen, past sessions cannot be decrypted. TLS 1.3 also removed the older RSA key transport (where the client encrypted a secret under the server’s public key), precisely because it lacked forward secrecy.

The handshake is the foundation of web security, but its properties are often misunderstood. TLS authenticates the server to the client, not the user — client certificates exist but are rarely used. It encrypts data in transit, but the server itself still sees plaintext; TLS protects against eavesdroppers and tampering on the network, not against a compromised endpoint. And certificate validation is only as strong as the trust store: a certificate issued by any trusted CA for a name is accepted, which is why certificate transparency logs exist to make mis-issuance publicly visible.

A padlock does not mean a site is trustworthy — it means the connection to the site is encrypted and the certificate matched the domain. Phishing sites routinely serve valid TLS certificates. Also, “TLS” and “SSL” are not synonyms: SSL is the obsolete predecessor (SSL 3.0 was deprecated in 2015), and every modern connection is TLS, usually 1.2 or 1.3.