Skip to content
We areTOP 1%

How does the TLS handshake secure an HTTPS connection?

HardConceptTLS, Firewalls & Load Balancers
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Before any HTTP data is sent, TLS runs a handshake that authenticates the server and lets both sides agree on shared session keys. It uses asymmetric cryptography only to set up the session, then switches to fast symmetric encryption. In TLS 1.3 the handshake takes one round trip after the TCP handshake.

  • ClientHello: the client sends its supported TLS versions and cipher suites, a random value and a key share, its half of an ephemeral Diffie-Hellman key exchange.
  • ServerHello: the server picks a cipher suite and sends its own key share. Each side combines the two shares into the same secret, which an eavesdropper cannot compute, and derives the symmetric session keys from it.
  • The server then sends its certificate, a CertificateVerify signature proving it holds the matching private key, and a Finished message, all already encrypted. The client verifies them and sends its own Finished.
  • Fresh keys for every session give forward secrecy: recorded traffic stays safe even if the server's private key is stolen later. TLS 1.2 needed two round trips.

Example:

Client                                            Server
  | -- ClientHello (ciphers, random, key share) -->  |
  | <-- ServerHello (key share), Certificate,        |
  |     CertificateVerify, Finished   [encrypted]    |
  | -- Finished [encrypted] ---------------------->  |
  | == GET /  (AES-encrypted with session key) ===>  |

More in TLS, Firewalls & Load Balancers

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account