The Plain Picture#
Before a secret conversation you (1) check the other person's passport, (2) agree on a secret code word that nobody listening could figure out, and then (3) speak only in that code.
The Real Names#
TLS (Transport Layer Security) is the protocol that encrypts a connection. (Its old name was SSL; people still say "SSL certificate".)
HTTPS = HTTP sent inside a TLS-encrypted connection. Default port 443.
TLS gives three guarantees:
Under the Hood — the TLS 1.3 handshake#
After the TCP handshake (Networking 2: TCP, UDP and Ports Ch 5):
Browser studybuddy.app
│ │
│ ── ClientHello ──────────────────────────────────────────────────▶ │
│ "I speak TLS 1.3; these ciphers; my key-exchange share; │
│ I want the site studybuddy.app (SNI)" │
│ │
│ ◀──────────────────────────────────────────────────── ServerHello ─ │
│ "Cipher chosen; my key-exchange share" │
│ [from here on, encrypted] │
│ Certificate chain + signature proving it holds the private key │
│ Finished │
│ │
│ Browser: 1. check the certificate chain up to a trusted root CA │
│ 2. check it's for studybuddy.app and not expired │
│ 3. both sides compute the same symmetric key (Ch 10.2) │
│ │
│ ── Finished + first HTTP request (encrypted with AES) ───────────▶ │One round trip for TLS 1.3 (TLS 1.2 needed two). Repeat visits can even send data in the first flight ("0-RTT"), with a replay risk, so it's only used for safe requests.
SNI (Server Name Indication) — the client names the site it wants in the ClientHello, so one IP can serve many HTTPS sites (the TLS version of the
Hostheader, Ch 3).Forward secrecy: because each connection's key comes from fresh Diffie–Hellman values, stealing the server's private key later does not let anyone decrypt connections recorded in the past.
What an eavesdropper on café Wi-Fi can still see#
| Visible | Hidden |
|---|---|
| your IP and the server's IP (Networking 1: Addresses and Routing Ch 4) | the URL path and query (/notes/priya?page=2) |
| the port (443) | all headers, including cookies and Authorization |
| usually the site name (SNI, and your DNS lookup) | the body — passwords, notes, everything |
| how much data and when |
Gotchas
Certificate expiry is one of the most common causes of outages at big companies. Automate renewal and alert weeks before expiry.
"The padlock" means the connection is encrypted to that domain — not that the site is honest. Phishing sites have valid certificates too.
HSTS (
Strict-Transport-Securityheader) tells browsers "only ever use HTTPS for this site", so a first visit can't be silently downgraded to plain HTTP.TLS termination: usually the load balancer or reverse proxy does the TLS work and talks to your app over plain HTTP inside the private network (Ch 12). That's why your FastAPI app often never deals with certificates.
Check yourself
5 questionsWhat three guarantees does TLS provide?
Show answerHide answer
Confidentiality, integrity, authentication.
How many round trips does a TLS 1.3 handshake add?
Show answerHide answer
One (zero on some repeat connections).
What does the browser check about the certificate?
Show answerHide answer
That it chains up to a trusted root CA, that it's for the right domain, and that it hasn't expired (and the server proved it holds the private key).
On café Wi-Fi with HTTPS, can an attacker see which page on StudyBuddy you're reading? Your password?
Show answerHide answer
No and no — the path and body are encrypted. They can see you're talking to StudyBuddy's server (IP and usually the name).
What is forward secrecy?
Show answerHide answer
Each connection uses fresh key-exchange values, so a later stolen private key can't decrypt earlier recorded traffic.