December 5, 2026

The TLS Handshake Explained: What Happens Before an HTTPS Page Loads

A laptop browser address bar with a glowing padlock icon

With 100 milliseconds of round-trip delay added between a client and a test server, a TLS 1.3 handshake finished in about 105 milliseconds. The same connection forced down to TLS 1.2 took about 206. One protocol needs one round trip to set up encryption; the older one needs two. Every HTTPS page load starts with this exchange, the TLS handshake, in which a browser and a server that have never met agree on keys, check the server’s identity and lock the connection before a single byte of the web page moves. The test here used OpenSSL 3.0.13 and curl 8.5.0, and every message listed below came from OpenSSL’s own trace of the connection.

Video: Computerphile on YouTube

What TLS is for

Three protections

TLS 1.3 is specified in RFC 8446, “The Transport Layer Security (TLS) Protocol Version 1.3,” published in August 2018. Its abstract states the purpose plainly: TLS “allows client/server applications to communicate over the Internet” and is “designed to prevent eavesdropping, tampering, and message forgery.”

Those are three different jobs. Encryption stops eavesdropping. Integrity checks stop tampering. Authentication, usually through a certificate, stops an impostor from pretending to be the real server. HTTPS is simply HTTP carried inside a TLS connection.

The test setup

A self-signed certificate for localhost was generated with an elliptic-curve key, and openssl s_server served a page on a local port. openssl s_client -msg connected and printed every handshake message, and curl timed full connections through a small Python proxy that delayed traffic by 50 milliseconds each way.

A close up of a key in a door

The TLS 1.3 handshake, message by message

What the trace showed

The OpenSSL trace for a TLS 1.3 connection, with >>> for messages the client sent and <<< for what it received:

>>> ClientHello
<<< ServerHello
<<< EncryptedExtensions
<<< Certificate
<<< CertificateVerify
<<< Finished
>>> Finished
<<< NewSessionTicket
<<< NewSessionTicket

ClientHello

The client opens with a list of what it supports: protocol versions, cipher suites and, in TLS 1.3, a key share, its half of an elliptic-curve Diffie-Hellman exchange, guessed in advance. That guess is what saves a round trip.

ServerHello and the switch to encryption

The server picks a cipher suite and sends its own key share. At that moment, both sides can compute the same secret. Everything after this point is encrypted. RFC 8446 lists this among the major changes from TLS 1.2: “All handshake messages after the ServerHello are now encrypted.” The certificate itself travels encrypted in TLS 1.3, hidden from anyone watching the wire.

Certificate, CertificateVerify, Finished

The server sends its certificate, then a CertificateVerify message: a signature over the handshake so far, made with the certificate’s private key. That proves the server actually holds the key, not just a copy of a public certificate. A Finished message from each side confirms that both computed the same keys from the same transcript. The test connection reported Ciphersuite: TLS_AES_256_GCM_SHA384 and Signature type: ECDSA.

After the handshake

The two NewSessionTicket messages arrived after the handshake completed. They let the client resume a later connection faster without a full certificate exchange.

TLS 1.2 for comparison

More messages, more round trips

The same server, with the client restricted to TLS 1.2, produced this trace:

>>> ClientHello
<<< ServerHello
<<< Certificate
<<< ServerKeyExchange
<<< ServerHelloDone
>>> ClientKeyExchange
>>> ChangeCipherSpec
>>> Finished
<<< NewSessionTicket
<<< Finished

In TLS 1.2, the client doesn’t send its key share until it has seen the server’s choices, in ClientKeyExchange. That adds a second flight in each direction before encrypted data can flow. And the certificate went out before any encryption was set up, visible to anyone on the network path.

The negotiated result

TLS 1.2 settled on ECDHE-ECDSA-AES256-GCM-SHA384, an ephemeral elliptic-curve key exchange with the same AES-256-GCM encryption. The ciphers were nearly equivalent. The difference was in the choreography.

Fewer choices on purpose

The menu shrank too. On the test machine, openssl ciphers -s -tls1_3 listed just three default TLS 1.3 suites: TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256 and TLS_AES_128_GCM_SHA256. The same command for TLS 1.2 listed 27. A TLS 1.3 suite names only the encryption and hash; the key exchange and signature are negotiated separately, which is how the list stays short. Fewer combinations means fewer weak ones to misconfigure.

Silver magnifying glass on a book

Measuring the round trips

Adding delay

On a single machine, the whole handshake takes a few milliseconds either way; the first measurements, without added delay, came in at around 3 ms for both versions. To make the round trips visible, a small Python proxy delayed every chunk of data by 50 milliseconds in each direction, giving a 100 ms round trip, roughly like a connection across a continent.

The results

Measured with curl -w %{time_appconnect}, three runs each:

Version TLS handshake complete
TLS 1.3 0.107, 0.105, 0.105 s
TLS 1.2 0.206, 0.206, 0.208 s

One round trip versus two, almost exactly. RFC 8446 calls the standard TLS 1.3 exchange the “1-RTT handshake.” On a mobile network with high latency, that saved round trip is often the most noticeable speed difference between the two versions, since every new HTTPS connection pays for it.

What’s not counted here

A real connection also needs a TCP handshake first, one more round trip, plus a DNS lookup. In this test the proxy accepted the TCP connection locally, so only the TLS exchange felt the delay. On the open internet, a fresh TLS 1.3 connection over TCP needs about two round trips before the first byte of a request can go out, and TLS 1.2 about three.

Forward secrecy and the RSA question

Removing static key exchange

RFC 8446 lists another change: “Static RSA and Diffie-Hellman cipher suites have been removed.” In older TLS, a server could use its long-term RSA key directly to encrypt the session key. Anyone who recorded the traffic and later stole that private key could decrypt every recorded session.

Ephemeral keys

TLS 1.3 requires ephemeral key exchanges, fresh key pairs for each connection that are thrown away afterward. The certificate’s private key is used only to sign, proving identity. Stealing it later doesn’t unlock old conversations. That property is called forward secrecy, and in TLS 1.3 it’s mandatory rather than optional.

What the certificate check actually does

The test connection printed verify error:num=18:self-signed certificate. The encryption worked fine; what failed was trust. The certificate wasn’t signed by any authority the client trusted. A browser would show a full-page warning. Authentication is what stops an attacker who intercepts the connection from simply presenting their own certificate, which is why clicking past certificate warnings defeats the purpose of HTTPS even though the padlock math still runs.

Black and white modem router

Resuming a session

Reusing the ticket

Those NewSessionTicket messages get used on the next visit. OpenSSL can save a session to a file with -sess_out and offer it again with -sess_in. Doing that against the test server, the second connection reported Reused, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384, and its trace was noticeably shorter:

>>> ClientHello
<<< ServerHello
<<< EncryptedExtensions
<<< Finished
>>> Finished

No Certificate and no CertificateVerify. The server didn’t need to prove its identity again with a signature, because both sides already shared a secret from the earlier session. That saves the certificate’s bytes on the wire and the server’s signing work, which adds up on a busy site handling many repeat visitors.

Not faster in round trips, by itself

Timed through the same 100 ms delay proxy with Python’s ssl module, a full TLS 1.3 handshake took 0.109 seconds and two resumed handshakes took 0.103 seconds each, with Python confirming session_reused=True. Still one round trip. Resumption trims work and bytes but keeps the 1-RTT shape. Cutting that last round trip requires the client to send data in its very first message, which is what the 0-RTT mode does.

Zero round trips, with a catch

0-RTT resumption

TLS 1.3 also defines a mode for returning visitors. RFC 8446 describes “a zero round-trip time (0-RTT) mode” that saves a round trip at setup “at the cost of certain security properties.” Using a ticket from an earlier session, the client can send application data in its very first message.

The catch

The RFC is explicit about the trade: “This data is not forward secret, as it is encrypted solely under keys derived using the offered PSK,” and “There are no guarantees of non-replay between connections.” An attacker who captures a 0-RTT request could resend it. For a request that only reads a page, that’s mostly harmless. For one that places an order or moves money, it isn’t. Servers that enable 0-RTT generally accept it only for requests that are safe to repeat.

Checking a server

openssl s_client -connect example.com:443 -brief prints the protocol version, cipher suite and certificate details for any HTTPS server in one line each, and curl -v shows the negotiated version during an ordinary request. For a home lab running its own services, a self-signed or local certificate authority setup combined with TLS 1.3 gives the same one-round-trip handshake shown in the trace above.

Sources

  • RFC 8446, “The Transport Layer Security (TLS) Protocol Version 1.3” (Aug. 2018): https://www.rfc-editor.org/rfc/rfc8446

920 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *