The TLS handshake is the opening exchange of the Transport Layer Security protocol in which a client and a server negotiate the protocol version and cipher suite, authenticate the server (and optionally the client) and derive shared session keys before any application data is sent. In the field of Internet trust, it is the moment when certificates, signatures and key exchange turn an untrusted network path into an authenticated, confidential channel.
Every HTTPS page load, secure mail connection and most modern API calls on the Internet begin with this exchange. Its design determines how quickly a connection opens, which attacks it resists and whether past traffic stays private if a server key is later stolen.
How the TLS handshake establishes a secure session
The handshake works by combining ephemeral key agreement with certificate-based authentication, so that both sides compute the same secret without ever transmitting it. In TLS 1.3, the version defined in RFC 8446, the client opens with a ClientHello that lists supported versions, cipher suites, groups for key exchange and a key share computed in advance, usually on X25519 or the P-256 curve.
The server answers with a ServerHello carrying its own key share. From that point both sides derive handshake traffic keys with HKDF, and everything that follows is encrypted, including the certificate. The server then proves possession of its private key with a CertificateVerify signature over the transcript and closes its flight with a Finished message, a keyed hash of the whole exchange that detects tampering.
The following table lists the main TLS 1.3 handshake messages in order and the job each one performs.
| Message | Sender | Purpose |
|---|---|---|
| ClientHello | Client | Offers versions, cipher suites, key shares, SNI and ALPN |
| ServerHello | Server | Selects parameters and returns its key share |
| EncryptedExtensions | Server | Sends negotiated extensions under encryption |
| Certificate | Server | Delivers the certificate chain for validation |
| CertificateVerify | Server | Signs the transcript to prove key possession |
| Finished | Both | Confirms that both sides saw an identical transcript |
The client validates the certificate chain up to a trusted root, checks that the name matches the requested host and verifies the signature. Only after its own Finished message does the client treat the channel as authenticated, although TLS 1.3 allows it to send application data immediately after.
TLS 1.2 and TLS 1.3 handshakes compared
TLS 1.3 shortened the handshake to one round trip and removed legacy options that had caused real attacks. TLS 1.2 needs two round trips for a full handshake, sends the certificate in clear text and still permits static RSA key transport, which offers no forward secrecy.
The table below summarizes the practical differences between the two versions still widely deployed.
| Property | TLS 1.2 | TLS 1.3 |
|---|---|---|
| Round trips (full) | 2-RTT | 1-RTT |
| Resumption | Session IDs or tickets | PSK tickets, optional 0-RTT |
| Key exchange | RSA, DHE or ECDHE | (EC)DHE only |
| Forward secrecy | Optional | Mandatory |
| Certificate visibility | Sent in clear text | Encrypted |
| Cipher modes | CBC, RC4 and AEAD allowed | AEAD only |
| Renegotiation | Supported | Removed |
Because the ClientHello in TLS 1.3 guesses the key exchange group, a wrong guess triggers a HelloRetryRequest and costs an extra round trip. Clients therefore send shares for the groups servers most often prefer, and the newer hybrid groups that add a post-quantum key encapsulation component, such as X25519 combined with ML-KEM, make the ClientHello noticeably larger.
Authentication and trust decisions inside the handshake
The handshake authenticates a server by linking the negotiated keys to an X.509 certificate issued by a certificate authority that the client already trusts. The signature in CertificateVerify proves that the server holds the private key, while the chain proves that a trusted authority vouched for the binding between that key and the domain name.
Several neighboring trust mechanisms plug into this step. OCSP stapling lets the server attach a fresh revocation status, Certificate Transparency proofs show that the certificate was publicly logged, and Mutual TLS adds a CertificateRequest so the client must present its own certificate. HSTS and certificate pinning act outside the handshake but decide whether a failed validation may ever be bypassed.
- Server Name Indication (SNI) tells a shared server which certificate to present.
- ALPN selects the application protocol, such as HTTP/2 or HTTP/3, during the same exchange.
- Encrypted Client Hello (ECH) hides SNI from on-path observers where both sides support it.
Performance, resumption and latency trade-offs
Handshake cost has two parts: network latency from round trips and CPU time for signatures and key agreement. On a path with 80 ms round-trip time, the difference between a 2-RTT and a 1-RTT handshake is directly visible to users, which is why version choice matters for page speed.
Session resumption avoids repeating certificate validation by reusing a pre-shared key from an earlier session. TLS 1.3 can even carry application data in the first flight with 0-RTT early data, but that data is vulnerable to replay, so servers should accept it only for idempotent requests.
The following table compares the handshake modes by speed and security properties.
| Mode | Round trips before data | Forward secrecy | Main caveat |
|---|---|---|---|
| Full handshake | 1 | Yes | Full certificate processing |
| PSK with (EC)DHE | 1 | Yes | Depends on ticket key handling |
| PSK only | 1 | No for resumed data | Ticket key compromise exposes sessions |
| 0-RTT early data | 0 | No for early data | Replay possible |
Common handshake failures and how to diagnose them
Most handshake failures come from configuration mismatches rather than broken cryptography. The client reports them as alerts, such as handshake_failure, protocol_version or bad_certificate, and the alert name usually points to the cause.
The table below maps typical symptoms to their usual causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Unknown issuer error | Missing intermediate certificate | Serve the complete chain |
| Name mismatch | Certificate lacks the requested host | Reissue with correct SAN entries |
| protocol_version alert | Client or server limited to old versions | Enable TLS 1.2 and 1.3 |
| handshake_failure alert | No shared cipher suite or group | Align supported suites |
| Expired certificate | Renewal not automated | Automate renewal with ACME |
| Middlebox resets | Inspection device rejects new extensions | Update or bypass the device |
A frequent misconception is that encryption alone makes a connection safe. Without strict certificate validation, an attacker can complete a perfectly encrypted handshake while impersonating the server, so disabling verification in code is a serious security flaw, not a harmless workaround.
Understanding it simply
The TLS handshake is a short greeting. A browser and a website exchange it before they talk privately. First they agree on a common language. Then the website shows an ID card checked by a trusted authority. Finally, both sides arrive at the same secret key. That key is never sent across the network.
After the greeting, everything else travels in a locked envelope. Only those two parties can open it. If the ID card does not check out, the browser stops and warns the user. A private talk with an impostor is worse than no talk at all.
Applied in practice
An online retailer notices that its mobile checkout feels slow for customers on distant networks with round-trip times near 150 ms. Its operations team finds that the load balancer still negotiates TLS 1.2 with RSA key transport and a chain missing one intermediate certificate, which forces some clients to fetch it separately.
The team enables TLS 1.3 with ECDHE on X25519, serves the complete chain, turns on OCSP stapling and issues session tickets with keys rotated every few hours. Early data is accepted only for product page requests, never for payment calls. Measured handshake time on those distant networks drops by roughly one round trip, about 150 ms, and every connection now has forward secrecy.