What are SNI and ALPN in the TLS ClientHello, and why do network engineers care about them?
Show the answer
Say this first
SNI (Server Name Indication) is the hostname the client wants, sent in the ClientHello so a server hosting
many sites on one IP can pick the right certificate. ALPN (Application-Layer Protocol Negotiation) lists
the application protocols the client speaks, such as h2 and http/1.1, and the server picks one inside
the handshake, avoiding an extra round trip. Network engineers care because firewalls filter on SNI, load
balancers route on it, and a missing SNI or a proxy that does not offer h2 causes odd failures.
Go deeper
SNI in practice
- Without SNI the server returns its default certificate, and the client reports a name mismatch. Typical culprits: health checks or scripts connecting by IP, and old clients.
- Load balancers and reverse proxies use SNI to choose a certificate and a backend pool, even when they pass the TLS through without terminating it.
- Firewalls use it for URL categories and application identification. Encrypted Client Hello hides the real SNI behind an outer, generic one.
ALPN in practice
- HTTP/2 over TLS is selected only through ALPN
h2. A proxy in the middle that offers onlyhttp/1.1downgrades the connection. - gRPC needs HTTP/2. A TLS-terminating load balancer that does not negotiate
h2toward the client or the backend breaks gRPC calls. - QUIC uses ALPN too; HTTP/3 is
h3.
Testing
openssl s_client -connect 203.0.113.80:443 -servername shop.example.com -alpn h2,http/1.1The output shows the certificate the server chose for that name and ALPN protocol: h2 when HTTP/2
was selected.
They will ask next
A health check against a TLS backend fails with a certificate name error, but browsers are fine. Why?
The health check connects by IP without SNI, so the backend returns its default certificate. Configure the check to send the hostname as SNI, or relax name verification for health checks only.
What is domain fronting?
Using one hostname in the SNI and a different one in the encrypted HTTP Host header, so a censor sees an allowed domain while a shared CDN routes to another. Major CDNs now reject mismatches.
Traps
- Saying SNI is encrypted by TLS 1.3. It is not; only ECH hides it.