Course contentsShow
← Computer Science
Lesson 2443 of 2,87255. Web SecurityFree lesson

The TLS Handshake: Establishing Secure Connections

Learn the step-by-step process of the TLS handshake that negotiates encryption before data transfer.

The TLS Handshake: Establishing Secure Connections

You'll learn the step-by-step negotiation process that TLS uses to establish encryption between a client and server before any sensitive data is transmitted.

The Dance Before the Conversation

Think of the TLS handshake like two diplomats meeting for the first time—before discussing sensitive matters, they must agree on a common language, verify each other's credentials, and establish a private communication channel. The TLS handshake does exactly this for computers.

The Handshake Steps

When your browser connects to an HTTPS website, the TLS handshake unfolds in these stages:

1. ClientHello

The client sends supported TLS versions, cipher suites (combinations of encryption algorithms), and a random number for later use.

2. ServerHello

The server responds by selecting a TLS version and cipher suite from the client's list, sends its own random number, and provides its digital certificate (containing its public key).

3. Certificate Verification

The client verifies the server's digital signature on the certificate to confirm it's talking to the legitimate server, not an imposter.

4. Key Exchange

Using asymmetric cryptography (like RSA or Diffie-Hellman), both sides establish a shared secret. The client might encrypt a "pre-master secret" with the server's public key, or they might use ECDH to compute a shared secret without transmitting it.

5. Session Keys Generation

Both sides use the random numbers and shared secret to independently compute identical symmetric session keys.

6. Finished Messages

Both parties send encrypted "finished" messages using the new session keys to confirm the handshake succeeded.

Now symmetric encryption (AES) takes over for fast, secure data transfer.

Key Takeaway: The TLS handshake combines asymmetric cryptography for secure key exchange, digital signatures for authentication, and hash functions for integrity—all to negotiate symmetric session keys that protect your data throughout the connection.