You type https://example.com, press Enter, and a page appears. Between those two moments, your browser and a server you've never met agree on a secret, check each other's identity, and start encrypting everything. This post follows one request through that process.
Layer 1: The 30-second version
HTTPS is just HTTP inside an encrypted tunnel (TLS). Setting up the tunnel does three jobs:
- Confidentiality: nobody on the network can read the traffic.
- Integrity: nobody can change it without being noticed.
- Authentication: you're really talking to example.com, not an impostor.
Everything below is how those three jobs get done.
Layer 2: The journey, step by step
Browser Server
| 1. DNS lookup: example.com -> IP |
| 2. TCP connection (SYN, SYN-ACK, ACK) |
| |
| 3. ClientHello ----------------------------> |
| (versions, ciphers, key share, hostname) |
| |
| <--------------------------- 4. ServerHello |
| (chosen cipher, server key share) |
| [from here on, everything is encrypted] |
| <--------- 5. Certificate + signature + done |
| |
| 6. Verify certificate, send "Finished" ----> |
| |
| 7. GET / HTTP/1.1 (encrypted) ------------> |
| <------------------ 8. 200 OK (encrypted) |
1. DNS. Your browser turns the name into an IP address. This step isn't encrypted by default, though DNS over HTTPS exists.
2. TCP. A normal connection is opened to port 443. (HTTP/3 uses QUIC over UDP instead, but the TLS idea is the same.)
3. ClientHello. The browser says: "Here are the TLS versions and ciphers I support, here's my half of a key exchange, and I'm looking for example.com." That last part is called SNI, and it lets one IP address host many sites.
4. ServerHello. The server picks a cipher and sends its half of the key exchange. Both sides can now compute the same shared secret without ever sending it. From this point the rest of the handshake is encrypted.
5. Certificate. The server sends its certificate and proves it owns the matching private key by signing the handshake with it.
6. Verification. Your browser checks the certificate. If anything fails, you get the scary warning page. If it passes, both sides send "Finished" messages.
7-8. The actual request. Only now does GET / go out, already encrypted.
In TLS 1.3 this whole handshake takes one round trip before your request can go out.
Layer 3: The details people get wrong
The key exchange doesn't send the key
Both sides use an ephemeral Diffie-Hellman exchange (usually on the curve X25519). Each side sends a public value, and each combines the other's public value with its own private one to reach the same secret. An eavesdropper sees both public values but can't compute the secret.
Because the keys are ephemeral (new for every connection), recording today's traffic and stealing the server's key later doesn't decrypt it. That property is called forward secrecy.
The certificate doesn't encrypt anything
A common misconception is that the certificate encrypts traffic. It doesn't. Its job is identity: it binds a domain name to a public key, and a Certificate Authority (CA) signs that binding.
Your browser checks:
- The chain: the leaf certificate is signed by an intermediate, which is signed by a root CA already trusted by your OS or browser.
- The name: the domain matches one of the names in the certificate (the Subject Alternative Names).
- The dates: the certificate hasn't expired or been issued for the future.
- The proof: the server signed the handshake with the private key matching the certificate, so it isn't just replaying someone else's certificate.
After the handshake
Both sides derive symmetric keys from the shared secret and use an AEAD cipher (AES-GCM or ChaCha20-Poly1305). It encrypts and authenticates each record, so tampering is detected. Symmetric crypto is fast, which is why the slow public-key part only happens during the handshake.
What HTTPS doesn't hide
- The IP address you connect to.
- The hostname (SNI) in most setups. Encrypted ClientHello is rolling out to fix this.
- The amount and timing of the data.
- Anything the server itself logs or leaks.
Try it yourself
See the handshake from the command line:
curl -v https://example.com
Look for the TLS version, cipher, and the certificate chain in the output.
Inspect the certificate directly:
openssl s_client -connect example.com:443 -servername example.com -tls1_3 -showcerts
In Chrome or Firefox, click the padlock, open the certificate details, and compare the issuer and validity dates with what you saw above.
For the adventurous: set the SSLKEYLOGFILE environment variable, capture traffic in Wireshark, and load the key log. You can then watch your own HTTPS request decrypt.
Recap
| Step | Purpose |
|---|---|
| Key exchange (ECDHE) | Create a shared secret without sending it |
| Certificate + signature | Prove the server is who it claims to be |
| AEAD encryption | Keep the data private and tamper-proof |
HTTPS isn't one clever trick. It's three simple ideas that work together, and now you know where each one fits.
Top comments (0)