The web What happens during a TLS handshake? 4 min read

What happens during a TLS handshake?

Your browser and your bank have never met, and every message between them passes through strangers. How do they agree on a secret key out loud, in one quick back-and-forth?

  1. The problem: a secret, agreed in public

    Every request to your bank crosses networks run by strangers: café Wi-Fi, your internet provider, routers along the way. Any of them can read what passes through.

    Encryption fixes that, but only if both sides share a key. Your browser has never met this website, and sending a key across the network would be like posting a house key on a postcard.

    Your browser on the left and your bank’s website on the right, joined by a dashed line that passes through café Wi-Fi, an internet provider and a router. Everyone in between sees every byteBrowseryouWebsiteyour bankWi-FiISProuterHow do you share a key here?
    Everything you send passes through machines you don’t control.

    In short To talk privately, both sides need the same key, without ever sending it.

  2. Each side sends half and keeps a secret

    Your browser speaks first. Its hello lists the encryption it can use, the site name it wants, and a public value made from a random secret it keeps to itself.

    The website answers with its own public value. Each side then mixes its own secret with the other’s public value. The maths behind this, called a Diffie–Hellman key exchange, gives both sides the same result. Someone who saw only the two public values can’t work it out.

    Your browser picks a secret and sends a hello with its public value. The website picks its own secret and replies with its public value. Both then compute the same key, which never crossed the network.

    The two hellos. Nothing secret crosses the network.

    In short The key is worked out on both ends. It’s never sent.

  3. Proving it’s really the website

    A private line is no use if the other end is an impostor. Someone in the middle could run that same exchange with you and pretend to be your bank.

    So the website also sends its certificate, which says “this key belongs to bank.example”, signed by an authority your device already trusts. Then it signs the conversation so far with that certificate’s private key, which only the real site holds.

    Your browser checks the name, the dates, the authority and that signature. If any check fails, you get a full-page warning instead of the site. If they all pass, both sides send a short checksum of the whole conversation, and your real request follows, encrypted.

    After the two hellos, the website sends its certificate and a signature over the conversation, both already encrypted. Your browser checks them. Both sides send a Finished checksum, then your request travels encrypted.

    After the hellos, everything is encrypted. The locks mark it.

    In short The certificate and the signature prove who holds the other end of the key.

What TLS doesn’t do

It protects the trip, not the ends. A phishing site can get a valid certificate as easily as your bank can, so the padlock means the line is private, not that the site is honest.

It doesn’t hide where you’re going. Your network still sees the website’s IP address, and usually its name in that first hello.

And once your data arrives, TLS has nothing to say about how the website stores it.

Keep this

TLS makes the line private and proves who’s on the other end. It can’t tell you whether to trust them.

Check the name in the address bar. The handshake proved you’re talking to whoever owns that name, nothing more.
Key
Worked out on both ends from swapped public values. It never crosses the network.
Certificate
Ties the site’s name to a key, signed by an authority your device trusts.
Signature
Proves the site holds that key’s private half, right now.
Limit
Private isn’t the same as safe. Phishing sites have padlocks too.

Questions worth carrying

Does anyone ever send the actual key?

No. Each side sends only a public value. The shared key is worked out separately on both ends, and a fresh one is made for every connection.

If someone records my traffic today and steals the site’s certificate key next year, can they read it?

Not with TLS 1.3. Every connection’s key comes from a fresh exchange, so a stolen certificate key can’t unlock old conversations. This is called forward secrecy.

Why does my browser block the page when a check fails?

A failed check means it can’t prove who’s on the other end, so anything you send might go to an impostor.

Sources

Last reviewed 9 November 2026.

Next byte · How the web works What is a digital certificate?