Sobes.tech
Senior

How does TLS/HTTPS work? What is encrypted, how does the handshake occur?

sobes.tech AI

Answer from AI

TLS (Transport Layer Security) provides a secure connection over TCP, and HTTPS is HTTP over TLS.

Handshake:

  1. The client sends ClientHello with supported TLS versions, cipher suites, and a random number.
  2. The server responds with ServerHello, selecting parameters, sending its certificate (with public key), and a random number.
  3. The client verifies the certificate, generates a pre-master secret, encrypts it with the server's public key, and sends it.
  4. Both compute the master secret and derive encryption keys from it.
  5. The exchange of confirmation messages completes the handshake.

What is encrypted:

  • All HTTP data after the handshake is encrypted with a symmetric key.
  • This ensures confidentiality and data integrity.

Thus, TLS protects data from interception and tampering, ensuring that the client communicates with the intended server.