TLS and HTTPS: who sees what on the way

A browser opens https://shop.example/orders over a café's Wi-Fi. Watch the two hellos agree on a secret, the certificate get checked, and what someone on the same Wi-Fi can still read.

Level: DeepWatch: 15 steps · ~70 secondsLoad a page yourselfRecall: 3 questions · 8 cardsCompare 4 certificates · who sees whatShell · Python

What you'll take away

  • Explain how the ClientHello and ServerHello key shares give both ends one secret
  • Check a certificate as a browser does: the chain to a root, the dates, the name, the key
  • Say what HTTPS hides and what the path still sees: the IP, the port, sizes, the SNI name
  • Know why a redirect to https isn't enough, and how HSTS and preload close the gap

The 1-minute version

Tap a point and the picture below plays that step.

4Compare them all
ClientHelloHTTPS · t = 60 ms
shop.example
browser
trusted roots
café Wi-Fi
ClientHello → …
Step 1 / 15 · step by step
2round trips before the request
0 / 4certificate checks passed
…page arrived at
2 / 6things the path has read

The picture: the browser at the front of the street, the server at the far end, and a café's Wi-Fi beside the road that every message passes. A light is one message, and a lock marks the encrypted ones. The note by the Wi-Fi says what it has read so far, the list by the browser shows its four checks of the certificate, and the vault holds the roots it trusts.

Step 4 · Every option at once, on one clock

Compare them all: TLS · HTTPS

The same page loaded four times; only the certificate the server sends differs. See which loads get the page, and where the browser stops the others.

0 ms
A good certificatehandshaking

Use it when Always: from a CA browsers trust, with every name the site answers to in its SAN list

Skip it when Renewing by hand: let an ACME client (Let's Encrypt's, for one) renew it automatically

A model: 30 ms each way is a round number, not measured. The code below has openssl check the same certificates for real on this machine. Press any tile to see it large above, with when it fits.

What the path can still read

WhatHTTPSHTTPS + ECH
The server's IP address and portvisiblevisible
The site's namevisible (SNI)hidden; the provider's public name shows
The certificatehidden in TLS 1.3 (TLS 1.2 sent it in the clear)hidden
The path, query string, headers and cookieshiddenhidden
The page itselfhiddenhidden
Sizes and timingvisiblevisible

Hidden also means it can't be changed unnoticed: every record carries a tag that only the two ends can make. The DNS question for the name goes out before any of this, in the clear unless the device uses encrypted DNS (DNS over HTTPS or over TLS).

The chain and the roots

The server sends its own certificate and the intermediate one that signed it. The intermediate was signed by a root, and the roots come with the device or the browser: Apple, Microsoft, Mozilla and Chrome each keep a list and decide which authorities go on it. The browser checks every signature up to a root on that list, then the dates, then that the name is in the certificate's SAN list. A certificate proves nothing by itself; anyone can make one for any name, which is exactly what the fake in step 5 is. Browsers also want proof that a public certificate was written to Certificate Transparency logs, so a certificate issued by mistake can be found.

How long a certificate lasts

The CA/Browser Forum's ballot SC-081 (passed in April 2025) shortens the longest a public certificate may be valid: 398 days until March 2026, 200 days from 15 March 2026, 100 days from 15 March 2027 and 47 days from 15 March 2029. A certificate that leaks or was issued wrongly stops working sooner, and renewing by hand stops being practical: ACME (RFC 8555) clients such as the ones Let's Encrypt uses renew on their own.

HSTS and the preload list

Strict-Transport-Security (RFC 6797) tells the browser to use only https for this host for max-age seconds, and its subdomains too with includeSubDomains. The browser then changes http:// to https:// itself, before anything goes out, and won't let anyone click past a certificate warning for that host. It only counts when it arrives over HTTPS, so the very first visit is still open; the preload list built into browsers closes that gap. To join it (hstspreload.org), the site redirects http to https, serves every subdomain over https, and sends max-age of at least a year with includeSubDomains and preload.

ECH today

Encrypted Client Hello became RFC 9849 in March 2026, with RFC 9848 for its key in a DNS HTTPS record. The browser sends an outer ClientHello with the provider's public name, and the real one, with the real name, encrypted inside. Chrome (since 117) and Firefox (since 119) use it by default when a site publishes a key; Firefox needs DNS over HTTPS for it, since a plain DNS question would give the name away anyway. It helps most where many sites share a provider's addresses: a site alone on its IP is still easy to guess.

What the picture leaves out

TLS 1.2 needed two round trips and sent the certificate in the clear. A browser coming back can resume a session and even send its request in the first flight (0-RTT), but those early bytes can be replayed by someone on the path, so servers accept them only for requests that are safe to repeat. The key share itself is changing: Chrome (since 131) sends X25519MLKEM768, a hybrid that also holds against a future quantum computer, and the OpenSSL that ran the code below picked it too. Revocation of a certificate before it expires mostly reaches browsers through lists they update themselves, which is part of why lifetimes are getting short. HTTP/3 puts TLS 1.3 inside QUIC's handshake, so TCP's round trip and TLS's become one.

In real code

tls.sh
#!/bin/sh
# needs: openssl
# A certificate authority of our own, certificates for shop.test signed by it, and openssl s_server speaking TLS on
# 127.0.0.1 (no internet needed). openssl s_client then checks each one the way a browser does: the chain up to a root
# it trusts, the name, the dates. Run: sh tls.sh   (OpenSSL 3.4 or newer for -not_before; macOS: brew install openssl)
set -eu
tmp=$(mktemp -d)
pids=""
trap 'for p in $pids; do kill "$p" 2>/dev/null; wait "$p" 2>/dev/null || :; done; rm -rf "$tmp"' EXIT
cd "$tmp"
key() { openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out "$1.key"; }

# 1. A root of our own. Real roots ship with the operating system and the browser.
key root
openssl req -x509 -new -key root.key -days 30 -subj "/CN=Test Root" -out root.pem \
  -addext "basicConstraints=critical,CA:TRUE" -addext "keyUsage=critical,keyCertSign"

# 2. "This public key belongs to shop.test", signed by the root: one valid now, one whose dates have passed.
key shop
openssl req -new -key shop.key -subj "/CN=shop.test" -out shop.csr
printf 'subjectAltName=DNS:shop.test\nextendedKeyUsage=serverAuth\n' > leaf.ext
openssl x509 -req -in shop.csr -CA root.pem -CAkey root.key -days 30 -extfile leaf.ext -out good.pem 2>/dev/null
openssl x509 -req -in shop.csr -CA root.pem -CAkey root.key -extfile leaf.ext -out expired.pem \
  -not_before 20250101000000Z -not_after 20250201000000Z 2>/dev/null

# 3. What someone on the path could make: the right name, signed by nobody the client trusts.
openssl req -x509 -new -key shop.key -days 30 -subj "/CN=shop.test" -addext "subjectAltName=DNS:shop.test" -out fake.pem

# A TLS server per certificate; the OS picks each port.
serve() {
  openssl s_server -accept 127.0.0.1:0 -cert "$1.pem" -key shop.key -www >"$1.log" 2>&1 &
  pids="$pids $!"
  n=0
  until grep -q '^ACCEPT' "$1.log"; do n=$((n + 1)); [ "$n" -lt 100 ] || exit 1; sleep 0.05; done
  sed -n 's/^ACCEPT 127\.0\.0\.1://p' "$1.log"
}
good=$(serve good) expired=$(serve expired) fake=$(serve fake)

# Connect as a browser would: ask for a name (SNI), trust only root.pem, check the name, stop on any error.
check() {
  echo "== $1"
  openssl s_client -connect "127.0.0.1:$2" -servername "$3" -verify_hostname "$3" -CAfile root.pem \
    -verify_return_error -brief </dev/null 2>&1 |
    grep --color=never -E '^(Protocol version|Ciphersuite|Negotiated TLS1.3 group|Peer certificate|Verification|.*verify error)' || :
}
check "shop.test, valid certificate" "$good" shop.test
check "the same server, asked for other.test" "$good" other.test
check "an expired certificate" "$expired" shop.test
check "the right name, not signed by our root" "$fake" shop.test

# The first line of an HTTP answer that went through the encrypted connection.
echo "== a request over TLS"
printf 'GET / HTTP/1.0\r\n\r\n' | openssl s_client -connect "127.0.0.1:$good" -servername shop.test \
  -verify_hostname shop.test -CAfile root.pem -verify_return_error -quiet 2>/dev/null | head -1
Run: sh tls.sh (every server runs on 127.0.0.1 on your machine; no internet needed)It printed:
== shop.test, valid certificate
Protocol version: TLSv1.3
Ciphersuite: TLS_AES_256_GCM_SHA384
Peer certificate: CN=shop.test
Verification: OK
Negotiated TLS1.3 group: X25519MLKEM768
== the same server, asked for other.test
verify error:num=62:hostname mismatch
== an expired certificate
verify error:num=10:certificate has expired
== the right name, not signed by our root
verify error:num=18:self-signed certificate
== a request over TLS
HTTP/1.0 200 ok

A root of our own, certificates for shop.test signed by it (one valid, one expired), a self-made one with the right name, and openssl s_server on 127.0.0.1. openssl s_client checks each the way a browser does: the chain up to the root it was given, the name, the dates. Really run; below is what it printed.

Common questions

What does HTTPS protect, and what can others still see?

The content, path, query string, headers and cookies are encrypted, and can't be changed on the way without it showing. The destination IP, the port, and sizes and timing still show, and so does the site's name in SNI unless ECH is used.

Table: what's hidden, what isn't

How does the TLS handshake work?

The browser sends a ClientHello with a key share and the site's name; the server answers with a ServerHello and its own key share, and both compute the same secret. The server then sends its certificate, a signature and Finished, encrypted. The browser checks them and sends its Finished with the first request.

How does a browser decide a certificate can be trusted?

The site's certificate is signed by an intermediate CA, which is signed by a root in the device's or browser's trust store. The browser checks each signature up to that root, then the dates and the name. The server sends its own certificate and the intermediate; the root is already on the device.

Read: the chain and the roots

What happens if someone intercepts HTTPS on public Wi-Fi?

They can answer in the server's place, but they'd have to present a shop.example certificate that chains to a root the device trusts, which they can't. So the browser stops before any request or cookie goes out. With HSTS there's no button to click past the warning either.

What is HSTS, and why do I need it if I already redirect to https?

A redirect only happens after the first request has already gone out readable, and someone on the path can change it. HSTS tells the browser to use https for the site on its own for max-age seconds; the very first visit is covered by the preload list built into browsers.

Read: HSTS and preload

What is ECH (Encrypted Client Hello)?

A TLS 1.3 extension (RFC 9849, March 2026) that encrypts the real ClientHello, name included, with a key the site publishes in a DNS HTTPS record. The path sees only the provider's public name. It works when both the browser and the site support it.

Read: ECH today

How long can a TLS certificate be valid now?

Since 15 March 2026, at most 200 days, falling to 100 days in March 2027 and 47 days in March 2029, under the CA/Browser Forum's ballot SC-081. Renewing by hand no longer keeps up; let ACME renew automatically.

Next lesson

Cookies and sessionsLevel: Intermediate

The channel is encrypted now; next, what a login cookie still needs: Secure, HttpOnly, SameSite and a new id at every login.