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:
- The client sends
ClientHellowith supported TLS versions, cipher suites, and a random number. - The server responds with
ServerHello, selecting parameters, sending its certificate (with public key), and a random number. - The client verifies the certificate, generates a pre-master secret, encrypts it with the server's public key, and sends it.
- Both compute the master secret and derive encryption keys from it.
- 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.