Postcards
Sending a plain HTTP request is like sending a postcard. Every sorting office on the way can read it, and a dishonest one could even change what it says before passing it on.
HTTPS puts every letter in a locked box. The sorting offices still carry it, but they only see the outside, and if anyone forces the box open, you can tell.
What TLS gives you
HTTPS is ordinary HTTP sent inside a TLS connection (Transport Layer Security, formerly SSL). TLS gives three guarantees:
- Confidentiality: traffic is encrypted, so the network sees only ciphertext.
- Integrity: every record is authenticated, so modified data is detected and rejected.
- Authentication: the server proves its identity with a certificate.
Observers can still see which server you're talking to (its IP address, and usually its name), and roughly how much data flows, but not the URLs, headers, cookies or bodies.
Agreeing on a lock
How can two strangers agree on a secret when everything they send can be read? Each of you mixes your own secret ingredient with a shared one and posts the mixture. Then each of you adds your secret ingredient to the other's mixture. You both end up with the same final mix, and nobody watching can make it from what was posted.
The handshake
TLS 1.3 needs one round trip before data flows:
- ClientHello: supported cipher suites plus the client's key share, an ephemeral (Elliptic Curve) Diffie-Hellman public key.
- ServerHello: the chosen suite and the server's key share, followed (already encrypted) by its certificate, a signature proving it holds the certificate's private key, and Finished.
- Both sides derive the same session keys from the two key shares. The keys themselves never cross the wire.
- The client checks the certificate, sends Finished, and HTTP requests follow, encrypted with a fast symmetric cipher such as AES-GCM or ChaCha20-Poly1305.
Because the keys are ephemeral, recording traffic today and stealing the server's private key later still doesn't decrypt it. That property is called forward secrecy.
The notary's stamp
A locked box doesn't help if you agreed on the lock with the wrong person. So the shop shows an ID card stamped by a notary, someone your browser already trusts. A pretend shop can make its own card, but it can't get a real notary's stamp for a name that isn't theirs.
Certificates and the chain of trust
A certificate binds a domain name to a public key and is signed by a certificate authority (CA). The CA only signs after the site proves it controls the domain, for example by serving a token over HTTP or adding a DNS record (that's what Let's Encrypt automates).
Browsers ship a root store of trusted CAs. The server sends its certificate plus any intermediate certificates, and the browser checks that:
- each signature chains up to a trusted root,
- the name matches the site,
- it hasn't expired or been revoked.
If any check fails, the browser stops before sending a single byte of the request.
HSTS: a Strict-Transport-Security header tells the browser to use HTTPS for this site from now on, so a
later http:// link can't be downgraded by an attacker.
Mutual TLS: servers can ask clients for certificates too. Service meshes use this between internal services.
Inspect it: openssl s_client -connect shop.com:443 -servername shop.com prints the certificate chain and the
negotiated protocol.