TLS Handshake Explained: How Your Browser Trusts a Website

TLS handshake explained in plain terms means understanding the brief, invisible negotiation your browser performs before it trusts a website with your passwords and card numbers. The central question is how two computers that have never met can agree on a secret nobody else can discover, and the answer is a handshake: a short exchange of messages that authenticates the server, agrees on encryption, and sets up a session, all in a fraction of a second.

The TLS handshake is the opening phase of a Transport Layer Security connection, the protocol behind the padlock in your address bar. Before any web page, login, or payment travels, the browser and the server use the handshake to prove who the server is, agree on how to encrypt, and derive the session keys that protect everything after it.

It happens on every secure connection you make, thousands of times a day, and you never see it. This article walks through it step by step, explains the cryptography in plain language, and shows what can go wrong when it fails.

Key takeaways

  • The TLS handshake authenticates the server and agrees on encryption before any data flows.
  • Certificates, signed by trusted authorities, are how the browser knows the server is genuine.
  • Key exchange lets both sides derive a shared secret over a public channel.
  • TLS 1.3 completes the handshake in one round trip, half the time of TLS 1.2.
  • A failed handshake means no connection, which is the system working as designed.

What the handshake has to achieve

A handshake has three jobs, and each one matters. First, authentication: the browser must be sure it is talking to the real website, not an impostor sitting in the middle. Second, agreement: both sides must settle on a cipher suite, the exact recipe of algorithms they will use. Third, key exchange: they must derive a shared secret key that encrypts the session, even though every message so far has crossed a network anyone could watch.

The third job is the clever one, and it relies on asymmetric cryptography. Each side has a pair of keys, one public and one private, and the mathematics of those keys lets two strangers agree on a secret in the open. The private key never leaves its owner, and the public key is, as the name says, public.

Everything after the handshake uses symmetric encryption, where both sides share one key, because symmetric encryption is far faster for bulk data. The handshake exists to deliver that key safely, and then it steps aside. Our guide to the OSI model explains where TLS sits in the stack, and our guide to DNS over HTTPS explains how even the lookup before the handshake is now protected.

The handshake step by step

It starts with the ClientHello. The browser sends the server a message listing the TLS versions and cipher suites it supports, plus a random number it generated for this connection. The random number matters: it guarantees that every session’s keys are fresh, even if everything else stays the same.

The server answers with a ServerHello, choosing one TLS version and one cipher suite from the client’s list, and sending its own random number. In the same flight it sends its certificate, which contains its public key and its name, signed by a certificate authority the browser trusts, and a key share for the key exchange.

The browser checks the certificate carefully. It verifies the signature against its built-in list of trusted authorities, checks the name matches the site it asked for, and checks the certificate has not expired or been revoked. If any of those checks fail, the browser stops and shows a warning, and that warning is the system working, not a nuisance to click through.

Then both sides do the maths. Using the key shares they exchanged, each derives the same shared secret independently, without ever sending it across the network. From that secret and the two random numbers, they derive the session keys, and the handshake finishes with a short encrypted message from each side proving it computed the same keys. From here on, everything is encrypted.

Certificates and trust

Certificates are the handshake’s identity documents. A certificate binds a public key to a name, like example.com, and it is signed by a certificate authority, an organisation whose job is to check that the applicant really controls that name before signing.

Browsers ship with a list of trusted authorities, and they trust any certificate signed by one of them. That chain of trust is the weak point of the whole system: if an authority is careless or compromised, it can issue a certificate for a name it should not, and browsers will believe it. Certificate Transparency logs, public records of every certificate issued, exist to catch exactly that.

Most certificates today are free and automatic, thanks to Let’s Encrypt, which issues them after verifying control of the domain and renews them every ninety days. Short lifetimes are deliberate: a stolen certificate is only useful for weeks, not years, and automation makes renewal painless.

A photograph of two people shaking hands across a desk in a bright modern office, a laptop and documents between them
A photograph of two people shaking hands across a desk in a bright modern office, a laptop and documents between them, shows what a handshake is for: two strangers agreeing, in the open, that they can trust each other.

TLS 1.3 and the faster handshake

TLS 1.2, the version that ran the web for a decade, needed two round trips for the handshake, and it supported a long list of old cipher suites and options, some of them weak. Every round trip is a delay, and every weak option is an attack surface, so the standard’s authors took a hard line with TLS 1.3.

TLS 1.3 completes the handshake in one round trip. The client guesses which key exchange the server will want and sends its key share in the first message, so the server can reply with everything needed to start encrypting. The client then sends its first encrypted request in its next message, and the page starts loading.

It also cut the old and the weak. Static RSA key exchange is gone, so every session uses forward secrecy, which means that even if a server’s private key is stolen later, past sessions cannot be decrypted. Older, broken ciphers were removed entirely, leaving five strong cipher suites, and the handshake itself is encrypted sooner, hiding details like the certificate from anyone watching.

The result is a handshake that is both faster and safer, which is a rare combination. TLS 1.3 is now the default nearly everywhere, and browsers have begun to refuse the oldest versions outright. Our guide to IPv6 explains the addressing layer beneath these connections.

Comparing TLS versions

The differences between versions are mostly about speed and safety, and the direction has been consistent: fewer round trips, fewer options, stronger defaults.

The table below sets out the main contrasts between the versions still in use.

Aspect TLS 1.2 TLS 1.3
Handshake round trips Two One, or zero on resumption
Forward secrecy Optional, depends on cipher Mandatory for all sessions
Cipher suites Many, including weak legacy ones Five strong suites only
Handshake encryption Certificate sent in the clear Encrypted after ServerHello
Session resumption Tickets and session IDs Pre-shared keys, 0-RTT option
Status Supported but ageing Current default

The practical result is that TLS 1.3 should be enabled everywhere, TLS 1.2 kept only for old clients that cannot be upgraded, and anything older switched off entirely.

When handshakes fail

A failed handshake usually means one of a few things. An expired certificate is the most common, and it is a server problem, not a browser problem, which is why the browser refuses to proceed. A name mismatch means the certificate belongs to a different site, which can be a misconfiguration or an attack, and the browser cannot tell which.

An old client meeting a modern server can fail on cipher suites: if they share no algorithm they can both use, there is nothing to agree on, and the connection dies. That is why servers keep TLS 1.2 enabled for the moment, as a bridge for clients too old for 1.3.

The right response to a browser warning is to stop. Clicking through a certificate warning to reach a login page is exactly the mistake the warning exists to prevent, and a genuine site with an expired certificate will be fixed by its owners, usually within hours.

TLS handshake checklist

  • Enable TLS 1.3 and keep TLS 1.2 only for old clients.
  • Disable TLS 1.0 and 1.1 everywhere; they are broken.
  • Automate certificate renewal so expiry never happens.
  • Use certificates with short lifetimes and strong keys.
  • Check your configuration with an independent scanner yearly.
  • Enable forward secrecy on every cipher you offer.
  • Watch for certificate expiry alerts, not just uptime alerts.
  • Prefer 0-RTT only for safe, read-only requests.
  • Never ask users to click through a certificate warning.

Frequently asked questions

What is a TLS handshake?

It is the opening exchange of a secure connection, in which the browser and server authenticate the server, agree on encryption, and derive the session keys that protect everything after it.

How long does a TLS handshake take?

With TLS 1.3, one round trip, which is a few milliseconds on a nearby server and a tenth of a second or more on a distant one, plus a little computation on each side.

What is forward secrecy?

The guarantee that each session uses fresh keys, so stealing a server’s private key later does not let an attacker decrypt sessions recorded in the past.

Why does my browser warn about a certificate?

Because the certificate failed a check: it may be expired, revoked, issued for a different name, or signed by an authority the browser does not trust.

What is 0-RTT in TLS 1.3?

A way for a returning client to send encrypted data in its very first message, with no handshake delay, at the cost of replay risk for requests that change things.

Is TLS the same as SSL?

TLS is the successor to SSL. SSL is obsolete and insecure, and every modern “SSL certificate” is really a TLS certificate, with the old name kept out of habit.

The bottom line

TLS handshake explained in one line is this: prove who you are, agree on how to encrypt, and derive a secret key, all before a single byte of real data moves.

It is a small piece of mathematics that runs thousands of times a day on your behalf, and the padlock in your browser is the visible end of that invisible negotiation.

This article is general information about how the TLS handshake works, not advice about configuring it for a particular system.

Latest articles

Scroll to Top