SNI (Server Name Indication) is a TLS extension that allows a client to specify which hostname it wants to connect to during the TLS handshake. This is essential when multiple websites share the same IP address.
Here's how SNI fits into the TCP/TLS establishment:
What SNI is:
SNI is a field in the TLS Client Hello message that contains the hostname the client wants to reach. It's sent in plaintext during the handshake, before encryption is established.
What SNI is for:
Virtual hosting: Allows multiple SSL certificates on one IP address
CDNs: Content delivery networks can serve different sites from the same edge server
Load balancers: Can route traffic to appropriate backend servers based on hostname
Certificate selection: Server knows which certificate to present to the client
Example SNI in Client Hello:
code
Extension: server_name (len=19)
Type: server_name (0x0000)
Length: 19
Server Name Indication extension
Server Name list length: 17
Server Name Type: host_name (0)
Server Name length: 14
Server Name: example.com
Without SNI, servers could only present one certificate per IP address, making it impossible to host multiple HTTPS sites on the same server efficiently. SNI solved this "one certificate per IP" limitation that existed in early SSL/TLS implementations.