TLS 1.3 handshake

Anyone on the network can read what a browser sends. Before its first request, browser and server agree on a secret key in one round trip, and the server proves it is the site asked for.

Assembling the machine…

Timing · 50 ms a round trip

  1. Browser to Web server, SYN: 0 to 25 ms

Step 1 / 7

TCP first: SYN

First the browser opens a line (TCP): its SYN takes 25 ms to cross the network.

Event log · 1
  1. 25.00 msTCPSYN → open a connection

The concept

Anyone on the network can read what a browser sends. Before its first request, browser and server agree on a secret key in one round trip, and the server proves it is the site asked for.

The TLS 1.3 handshake is how a client and a server set up an encrypted, authenticated connection before any application data flows. Defined in RFC 8446 in 2018, it takes one round trip on top of the TCP handshake: the client sends a key share in its very first message, the server answers with its own and with the rest of the handshake encrypted, and the client sends its request right after its Finished message.

Each side sends the public half of a fresh key pair. Combining it with its own private half, each side computes the same secret, which no one watching the wire can. From the ServerHello on, everything is encrypted, the server's certificate included. The server proves it holds the certificate's private key by signing the handshake (CertificateVerify), and each side's Finished message, a MAC over the whole handshake, shows that no one tampered with it. By default only the server is authenticated.

TLS 1.2, defined in RFC 5246, takes two round trips: the key exchange completes only in the client's second flight, the certificate travels in plaintext, and no application data may be sent before the handshake is complete. A TLS 1.3 client meeting a TLS 1.2 server does not reconnect: the server answers the same ClientHello with a TLS 1.2 ServerHello.

With a ticket from an earlier TLS 1.3 connection, the client can resume with a pre-shared key and send its request in its very first flight: 0-RTT early data. RFC 8446 warns that this data is not forward secret and has no protection against replay across connections, so RFC 8470 lets clients put only safe requests, such as a GET, in early data, and lets servers refuse it with 425 Too Early.

Before trusting the keys, the client checks that the certificate names the host it meant to reach, here shop.example. RFC 9525 says to end the attempt with a bad certificate error when it does not. The 25 ms each way on this machine is modelled; the RFCs count round trips.

The run, step by step

Every scenario, in words.

What the machine plays, step by step. Beside a step, what a what-if switch plays in its place, or adds right after it.

Open https://shop.example

7 steps
  1. Play

    TCP first: SYN

    Before any TLS, TCP opens the connection. The browser sends SYN; it takes 25 ms to cross the network.

  2. Play

    SYN-ACK

    The server answers SYN-ACK. One round trip so far, 50 ms, and the client may now send data.

  3. Play

    ACK and ClientHello

    The browser completes TCP and sends its ClientHello in the same flight: the TLS versions and ciphers it supports, and a key share, the public half of a key pair it has just made. The ClientHello travels in plaintext.

    • With Meet a server that speaks only TLS 1.2 + Come back with a ticket (0-RTT)

      Play

      No ticket to resume with

      A TLS 1.2 server never issued a TLS 1.3 ticket, so there is nothing to resume and no early data. The browser completes TCP and sends a plain ClientHello, with its versions, its ciphers and a fresh key share.

    • With Come back with a ticket (0-RTT)

      Play

      ClientHello, and the request with it

      With a ticket from an earlier TLS 1.3 connection to this server, the browser resumes: its ClientHello carries the ticket's pre-shared key and an early_data flag, and right behind it goes the request, GET /orders, encrypted with keys derived from that key. It leaves at 50 ms, right after TCP.

    • With Meet a server that speaks only TLS 1.2 · adds a step after it

      Play

      The response

      200 OK. The first byte of the page arrives 200 ms after the first SYN.

  4. Play

    ServerHello, then everything encrypted

    The server picks TLS 1.3 and answers with its own key share. From the two shares, both sides compute the same secret, so everything after ServerHello is encrypted: the certificate, a signature over the handshake with the certificate's private key (CertificateVerify), and Finished, a MAC over the whole handshake.

    • With Come back with a ticket (0-RTT)

      Play

      The answer in the server's first flight

      The server accepts the early data and answers in its first flight: ServerHello, its encrypted extensions and Finished, then 200 OK. No certificate is sent on a resumption: the pre-shared key stands for the one checked last time. The response arrives at 100 ms.

    • With Meet a server that speaks only TLS 1.2

      Play

      A TLS 1.2 answer, in plaintext

      This server speaks only TLS 1.2. It answers the same ClientHello with a TLS 1.2 ServerHello, its certificate, its signed key exchange parameters and ServerHelloDone, all in plaintext: in TLS 1.2 the certificate is not encrypted.

  5. Play

    The browser checks the server

    The certificate names shop.example and chains to an authority the browser trusts; the signature matches the certificate's key; Finished matches the handshake the browser saw. The server is who it claims to be.

    • With Serve a certificate for another name

      Play

      The name does not match

      The certificate is valid, but for other.example: shop.example is not among its names. The browser must not go on with this server.

    • With Come back with a ticket (0-RTT)

      Play

      Fast, and replayable

      The browser ends its early data and sends its Finished. The request it sent early had a price: it is not forward secret, and nothing stops it being replayed on another connection. That is why RFC 8470 lets only safe requests, like this GET, go in early data.

    • With Meet a server that speaks only TLS 1.2

      Play

      The client's key exchange

      The browser checks the certificate and the signed parameters, then sends its own key share (ClientKeyExchange), ChangeCipherSpec and an encrypted Finished. The keys are only now agreed.

    • With Meet a server that speaks only TLS 1.2 + Serve a certificate for another name

      Play

      The name does not match

      The certificate, readable by anyone on the path in TLS 1.2, is for other.example: shop.example is not among its names. The browser must not go on.

  6. Play

    Finished, and the first request

    The browser sends its Finished and, in the same flight, the first request, GET /orders, encrypted with the application keys. It leaves 100 ms after the first SYN: one round trip for TCP, one for TLS.

    • With Serve a certificate for another name

      Play

      Alert, and close

      The browser sends a bad_certificate alert, encrypted under the handshake keys, and closes the connection. It sent no request: nothing reached a server it could not identify.

    • With Meet a server that speaks only TLS 1.2

      Play

      The server's Finished

      The server replies with its ChangeCipherSpec and Finished. Only now is the handshake complete: TLS 1.2 sends no application data before.

    • With Meet a server that speaks only TLS 1.2 + Serve a certificate for another name

      Play

      Alert, and close

      The browser sends a bad_certificate alert and closes the connection. It sent no request.

  7. Play

    The response

    The server answers 200 OK. The first byte of the page arrives 150 ms after the first SYN.

    • With Meet a server that speaks only TLS 1.2

      Play

      The first request, a round trip later

      GET /orders leaves 150 ms after the first SYN, one round trip later than with TLS 1.3.