Octet

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 only http/1.1 downgrades the connection.
  • gRPC needs HTTP/2. A TLS-terminating load balancer that does not negotiate h2 toward the client or the backend breaks gRPC calls.
  • QUIC uses ALPN too; HTTP/3 is h3.

Testing

Shell
openssl s_client -connect 203.0.113.80:443 -servername shop.example.com -alpn h2,http/1.1

The output shows the certificate the server chose for that name and ALPN protocol: h2 when HTTP/2 was selected.

Traps

  • Saying SNI is encrypted by TLS 1.3. It is not; only ECH hides it.
How did you do?Book 8.5 Example Systems