The TLS handshake is the exchange at the start of every HTTPS connection in which the client and server agree on encryption settings, derive shared keys, and the server proves its identity with a certificate. In TLS 1.3 it takes one round trip: the client sends a ClientHello with its key share, the server answers with a ServerHello, its certificate, a signature and a Finished message, and the client replies with its own Finished.
Below is a real TLS 1.3 handshake captured on a local test server, followed by what each message does and how TLS 1.2 differed.
A real TLS 1.3 handshake, captured with openssl
You can watch the handshake with OpenSSL. This setup used OpenSSL 3.2.1, a throwaway self-signed certificate, and a test server bound to 127.0.0.1:
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-keyout key.pem -out cert.pem -days 1 -subj "/CN=localhost"
openssl s_server -accept 127.0.0.1:8443 -cert cert.pem -key key.pem -naccept 1 -quiet &
openssl s_client -connect 127.0.0.1:8443 -servername localhost -CAfile cert.pem -msg
-msg prints every protocol message. Filtered to the handshake messages, the output was (>>> = sent by the client, <<< = received from the server):
>>> TLS 1.3, Handshake [length 013f], ClientHello
<<< TLS 1.3, Handshake [length 007a], ServerHello
<<< TLS 1.3, Handshake [length 0006], EncryptedExtensions
<<< TLS 1.3, Handshake [length 018d], Certificate
<<< TLS 1.3, Handshake [length 0050], CertificateVerify
<<< TLS 1.3, Handshake [length 0034], Finished
>>> TLS 1.3, ChangeCipherSpec [length 0001]
>>> TLS 1.3, Handshake [length 0034], Finished
<<< TLS 1.3, Handshake [length 00e9], NewSessionTicket
<<< TLS 1.3, Handshake [length 00e9], NewSessionTicket
And the negotiated result:
Protocol version: TLSv1.3
Ciphersuite: TLS_AES_256_GCM_SHA384
Peer certificate: CN=localhost
Signature type: ECDSA
Verification: OK
Server Temp Key: X25519, 253 bits
The client sent one message, the server answered with five, and the client sent its Finished. That is the single round trip. Lengths are in hexadecimal bytes; 013f is a 319-byte ClientHello.
The TLS 1.3 handshake step by step
1. ClientHello
The client opens with a random value, the protocol versions it supports, the cipher suites it accepts, and (the key change in TLS 1.3) a Diffie-Hellman key share in the key_share extension. It also lists the signature algorithms it accepts and, in the server_name extension (SNI), the hostname it wants, so a server hosting many sites knows which certificate to send. Here the client offered an X25519 key share, which the server accepted ("Server Temp Key: X25519").
2. ServerHello
The server picks one version and one cipher suite and returns its own key share. RFC 8446 says "the combination of the ClientHello and the ServerHello determines the shared keys." Both sides now compute the same secret from the two key shares, without it ever crossing the network. Everything after this point is encrypted.
3. EncryptedExtensions
Remaining settings that don't affect the keys, such as the application protocol (for example HTTP/2), sent encrypted.
4. Certificate and CertificateVerify
The server sends its certificate chain, then a CertificateVerify: per RFC 8446, "a signature over the entire handshake using the private key corresponding to the public key in the Certificate message." The certificate says who the key belongs to; the signature proves the server actually holds that key and that nobody tampered with the messages so far. The client checks the chain against its trusted root certificates and checks that the name matches. How that trust works is covered in what a certificate authority is.
5. Finished (server, then client)
Each side sends a Finished message, "a MAC (Message Authentication Code) over the entire handshake." If any earlier message had been altered in transit, the MACs wouldn't match and the connection would fail. The server can start sending application data straight after its Finished; the client can after it sends its own.
6. NewSessionTicket
After the handshake, the server sent two session tickets. A client can present one on a later connection to resume without a full certificate exchange.
Why the trace shows "TLS 1.2" and a ChangeCipherSpec
The unfiltered -msg output also shows lines like <<< TLS 1.2, RecordHeader [length 0005], and the client sent a ChangeCipherSpec even though TLS 1.3 doesn't use one. Both are deliberate. RFC 8446 has TLS 1.3 put the TLS 1.2 version number (0x0303) in its legacy version fields, and Appendix D.4 describes a "middlebox compatibility mode": because field measurements found that many network devices misbehave when they see TLS 1.3, the client "sends a dummy change_cipher_spec record," which makes "the TLS 1.3 handshake resemble TLS 1.2 session resumption." The real version is negotiated in an extension.
TLS 1.3 vs TLS 1.2 handshake
For comparison, the same server forced to TLS 1.2 (s_client ... -tls1_2 -msg) produced:
>>> TLS 1.2, Handshake [length 00cf], ClientHello
<<< TLS 1.2, Handshake [length 0041], ServerHello
<<< TLS 1.2, Handshake [length 018a], Certificate
<<< TLS 1.2, Handshake [length 0073], ServerKeyExchange
<<< TLS 1.2, Handshake [length 0004], ServerHelloDone
>>> TLS 1.2, Handshake [length 0025], ClientKeyExchange
>>> TLS 1.2, ChangeCipherSpec [length 0001]
>>> TLS 1.2, Handshake [length 0010], Finished
<<< TLS 1.2, Handshake [length 00ba], NewSessionTicket
<<< TLS 1.2, Handshake [length 0010], Finished
| TLS 1.2 | TLS 1.3 | |
|---|---|---|
| Round trips for a full handshake | 2 | 1 |
| When the client sends its key share | After the server's hello (ClientKeyExchange) | In the first message (ClientHello) |
| Server certificate | Sent in plain text | Encrypted |
| Key exchange | Static RSA allowed, or (EC)DHE | (EC)DHE or pre-shared key only; static RSA removed |
| Resumption with early data | No | Optional 0-RTT |
The round trip saved comes from guessing: the TLS 1.3 client sends a key share in its first message instead of waiting to learn what the server supports. If the guess is wrong, the server replies with a HelloRetryRequest and "the client needs to restart the handshake with an appropriate 'key_share' extension," costing the round trip back. Dropping static RSA matters for security too: RFC 8446 notes that "all public-key based key exchange mechanisms now provide forward secrecy," so a server key stolen later can't decrypt recorded traffic.
What a TLS handshake failure looks like
Run the same client without -CAfile, so it doesn't trust the self-signed certificate, and add -verify_return_error to make it abort:
verify error:num=18:self-signed certificate
...:error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:...
Verify return code: 18 (self-signed certificate)
The handshake stopped at step 4: the certificate arrived, but the client couldn't chain it to a trusted root. Browsers show the same failure as a full-page certificate warning. Other failures stop earlier, such as no shared protocol version or cipher suite (the ServerHello never comes), or later, such as a name that doesn't match the certificate. How to check an SSL certificate covers the commands for inspecting a live site's certificate.
What the handshake doesn't hide
The ClientHello travels before any keys exist, so it's readable by anyone on the path, including the SNI hostname. RFC 9849 calls plaintext SNI "perhaps the most sensitive information left unencrypted in TLS 1.3" and defines Encrypted Client Hello (ECH) to encrypt it, which works only when both browser and server support it. The rest of what HTTPS hides and exposes is in HTTP vs HTTPS.
Frequently asked questions
- How long does a TLS handshake take?
- A full TLS 1.3 handshake takes one network round trip between client and server, on top of the TCP connection setup. TLS 1.2 needed two round trips. The actual time depends on the network delay: with a 50 ms round-trip time to the server, the TLS 1.3 handshake adds about 50 ms.
- Is the TLS handshake encrypted?
- Partly. In TLS 1.3 the ClientHello and ServerHello are sent in the clear, and every handshake message after the ServerHello is encrypted, including the server's certificate. The hostname in the ClientHello (SNI) stays visible unless Encrypted Client Hello is used.
- What is a TLS handshake failure?
- It means the two sides could not agree or could not verify each other, so the connection was closed before any data was sent. Common causes are no shared protocol version or cipher suite, an expired or untrusted certificate, a hostname that doesn't match the certificate, or a middlebox interfering. The alert name in the error (for example handshake_failure or certificate_unknown) points to which.
- What is 0-RTT in TLS 1.3?
- 0-RTT (early data) lets a client that has connected before send application data in its very first message, using a key from the previous session. It saves a round trip, but RFC 8446 warns that this data is not forward secret and can be replayed, so servers should only accept it for requests that are safe to repeat.