Server Name Indication (SNI): What It Is and How It Works for Multi-Tenant SaaS

Server name indication (SNI) is a TLS extension. The client puts the hostname it wants to reach inside the ClientHello, before encryption starts. The server reads that name, picks the matching certificate, and finishes the handshake. One IP address and one port can then serve many HTTPS sites, each with its own certificate.
Before SNI, a server had to choose a certificate before it knew which site you wanted. That meant one certificate per IP, so one IP per HTTPS site. SNI fixed that. It is also why your customer's custom domain either works on a Tuesday afternoon or shows a scary browser warning.
This guide gives you the definition, then the operator's view: what SNI does when thousands of customer hostnames share one edge, what breaks, and how to debug it with openssl, curl and our free SSL checker.
What is Server Name Indication (SNI)?
SNI is the server_name field in the TLS ClientHello. The ClientHello is the first message of the handshake and it is sent in cleartext. The server sees the requested hostname before any encrypted data flows.
Why that matters: certificate selection happens during the handshake. The HTTP request comes after. Without SNI, the server has no hostname to look at when it has to pick a certificate.
One-line summary:
Client sends hostname (SNI) → server picks the matching certificate → handshake completes → HTTP
Hostheader follows inside the encrypted channel.
How SNI works, step by step
Here's the flow for https://shop.acme.com.
- The client resolves
shop.acme.comto an IP via DNS. - It opens a TCP connection to that IP on port 443.
- It sends a ClientHello. The
server_nameextension carriesshop.acme.com, along with supported TLS versions and cipher suites. - The server looks up a certificate for that name. If it has none, it falls back to a default certificate.
- The server sends its certificate and the handshake finishes.
- The client sends the HTTP request,
Hostheader included, inside the encrypted channel.
Client Server (one IP, many certs)
| ClientHello (server_name=shop.acme.com) |
|------------------------------------------>| pick cert for shop.acme.com
| ServerHello + certificate |
|<------------------------------------------|
| ... handshake completes ... |
| GET / (Host: shop.acme.com) [encrypted] |
|------------------------------------------>| route to the right site/tenant
We won't re-explain the whole handshake here. For the full sequence, see our glossary entry on the SSL/TLS handshake.
SNI vs the HTTP Host header
Both carry a hostname. They live at different layers and do different jobs.
| SNI | HTTP Host header | |
|---|---|---|
| Layer | TLS handshake | HTTP request |
| Visible on the network | Yes, in cleartext (without ECH) | No, it's encrypted |
| Chooses | The certificate | The site or tenant |
| Sent | Before encryption starts | After the handshake |
They usually match. When they don't, the failures get confusing:
- SNI is right, Host is wrong: valid certificate, wrong site or tenant.
- SNI is missing or wrong, Host is right: the server presents a default certificate. Browsers throw a name mismatch, and the page never loads.
Two layers, two lookups. Debug them separately.
Why SNI matters for multi-tenant SaaS and custom domains
Your customers point their own hostnames at your product. Often it's one CNAME each, and every hostname lands on the same edge. The edge has one IP (or a few) and thousands of names. SNI is the only hint it gets for deciding which certificate to present.
That sounds small. It is the opening line of a long list. A custom-domains "weekend feature" turns into:
- ACME rate limits
- Edge TLS termination
- SNI routing
- DNS health checks
- Certificate rotation
That's the "2–4 months of v1", plus on-call for cert outages. Every hostname needs its own certificate, issued at the right time, renewed before it expires, and served to the right SNI name. Your customer's whole experience of "custom domains" is whether that padlock shows up.
For the architecture pattern in more depth, see our glossary page on multi-tenant custom domains.
Worked example: how Domainee handles certificates for customer hostnames
Domainee is a custom-domains-as-a-service API for SaaS products. Your users connect their own domain. We handle automatic SSL, DNS monitoring and webhooks. Here is what's documented, nothing more.
1. Create the domain
One API call per customer hostname:
curl https://api.domainee.dev/v1/domains \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"hostname": "shop.acme.com",
"originUrl": "https://app.yourproduct.com"
}'
The response returns a CNAME your customer adds. It reports status and monitorStatus. This is an abridged, illustrative shape:
{
"id": "...",
"hostname": "shop.acme.com",
"status": "<status>",
"monitorStatus": "<monitor state>"
}
2. The customer adds one record
The CNAME target is edge.domainee.dev. The DNS record shows the Domainee name. It is not hidden. Apex domains are supported too. Where an apex provider disallows CNAME, we offer two anycast A records instead.
Not sure which provider your customer uses? GET /v1/domains/{id}/instructions detects the DNS provider from public NS records and returns provider-specific steps.
3. SSL happens on its own
SSL is automatic, through Let's Encrypt. The certificate is issued on the first request (on-demand TLS) and renewed automatically. Our docs also mention ZeroSSL in CAA guidance. Learn more about automatic SSL for SaaS custom domains.
On-demand TLS means no certificate is created up front for every name. The first request for a hostname triggers issuance. In general, on-demand TLS setups key off the SNI name the client sends, which is why SNI sits at the center of multi-tenant TLS.
4. We keep watching
Each domain is re-checked every 5 minutes, or on demand with POST /v1/domains/{id}/check. The monitor reports one of these states in monitorStatus:
unknowndns_not_resolvingdns_incorrectpending_sslactive_sslssl_failedssl_expired
Read them in two groups. The dns_* states point you at DNS. The *_ssl states point you at the certificate.
Preflight warns about CAA records that block Let's Encrypt. If a hostname sits in pending_ssl, a CAA record is worth checking.
Webhooks cover state changes: domain.verified, domain.failed, domain.expired and domain.monitor_updated. They're signed with HMAC-SHA256 in the x-domainee-signature header.
One more note: we run an edge network, and your customers' hostnames are served through it. Pricing is published. The free tier is up to 20 domains and 100 GB/month, never expires. Scale is $0.20/domain/month after the first 20. A card on file is required before the first domain, and it is charged $0 under the free tier.
Domainee is a product of Common Ninja. Common Ninja, Embeddable and Vidocu run on it in production.
How to test and debug SNI
Three tools cover most cases: openssl s_client, curl --resolve, and a free checker.
openssl s_client with and without -servername
Send an SNI name:
openssl s_client -connect HOST:443 -servername shop.acme.com </dev/null 2>/dev/null \
| openssl x509 -noout -subject -ext subjectAltName
Now the same command without -servername:
openssl s_client -connect HOST:443 </dev/null 2>/dev/null \
| openssl x509 -noout -subject -ext subjectAltName
Compare the two. With the right SNI, the certificate subject or Subject Alternative Names (SANs) should include the hostname. Without SNI, you will often see a default certificate that doesn't match. That difference shows the server selects certificates by SNI.
SANs matter more than the subject. Modern clients check the SAN list. If the hostname isn't in there, the certificate is wrong for that name.
curl --resolve
Test a hostname against a specific IP without touching DNS:
curl -vI --resolve shop.acme.com:443:203.0.113.10 https://shop.acme.com
curl sends SNI shop.acme.com and a matching Host header, but connects to the IP you gave it. That's handy for checking one edge node, or a new origin before a DNS cutover.
Common failures
- Wrong or default certificate returned. The server didn't get an SNI name, or has no certificate for it. Re-run
opensslwith-servername. Check that DNS actually points at the edge. - Handshake failure alerts. An alert number such as 40 (no cipher in common) or 70 (no protocol version in common) tells you what went wrong. If there's no alert and zero bytes are read, the server closed the socket. That points at an unknown SNI name or a client-side abort. Our glossary has the details: SSL handshake failed alert codes and fixes.
- A hostname stuck in
pending_ssl. Check DNS first (CNAME toedge.domainee.dev, or the A records at an apex). Then check for CAA records that block Let's Encrypt. Then force a re-check withPOST /v1/domains/{id}/check.
The free SSL checker
No terminal handy? Run your hostname through the free SSL certificate checker. No key needed. There's also a free SSL check API, one of 18 free public REST endpoints. Limits are 30 requests/minute and 500 requests/day per IP, and it's CORS-enabled. The same family includes an HTTP header checker.
Is SNI encrypted? ESNI and Encrypted Client Hello
Plain SNI is not encrypted. It's sent in the ClientHello in cleartext. Anyone on the network path can see which hostname you're connecting to, even though the rest of the session is encrypted.
ESNI (Encrypted SNI) was the first attempt to fix that. It was superseded by Encrypted Client Hello (ECH). ESNI hid only the server name. ECH encrypts the sensitive parts of the ClientHello, SNI included. The client gets the server's ECH public key through DNS.
What ECH changes for operators:
- Passive observers can no longer read the real hostname from the handshake.
- Middleboxes that filter or log by SNI lose that signal.
- Servers that terminate TLS still decrypt the inner ClientHello and still use the name to pick a certificate.
What ECH does not change:
- The destination IP address is still visible.
- DNS lookups are still visible unless the client uses encrypted DNS.
- On a shared IP with many tenants, the IP alone leaks less. On a dedicated IP, it can still give the site away.
We're not making any claims about Domainee and ECH here. This section is about the protocol.
Browser and client support, and what happens without SNI
Practically all modern browsers and HTTP clients send SNI. Some very old clients don't. When a client sends no SNI, the server has no name to match. It returns its default certificate, which usually doesn't match the site the user wanted.
The same thing happens when you connect by raw IP address. Hitting https://203.0.113.10 sends no SNI name. A certificate is issued for hostnames, not for your IP, so the default certificate shows up and you get a mismatch warning. That's not a broken site. It's SNI doing exactly what it does.
For most SaaS products today, you don't need to design around no-SNI clients. You do need to know that this is the first thing to rule out when someone reports a certificate error from a script or an old device.
FAQ
What is server name indication (SNI)? SNI is a TLS extension. The client sends the hostname it wants in the ClientHello, so the server can pick the right certificate for that name.
How does SNI work in a TLS handshake?
The ClientHello carries a server_name field. The server finds the matching certificate, presents it, and the handshake completes. The HTTP request follows inside the encrypted channel.
Why is SNI needed? Without it, a server must pick a certificate before it knows which site is requested. That forces one certificate per IP. SNI lets one IP and port serve many HTTPS sites.
What is the difference between SNI and the HTTP Host header?
SNI is sent during the TLS handshake and chooses the certificate. The Host header is sent in the encrypted HTTP request and chooses the site or tenant.
Is SNI encrypted? Not by default. Plain SNI travels in cleartext. Encrypted Client Hello (ECH) can hide it when both client and server support it.
What is Encrypted Client Hello (ECH) and how is it different from ESNI? ECH encrypts the sensitive parts of the ClientHello, including the server name. ESNI encrypted only the name and was superseded by ECH.
Do all browsers and clients support SNI? Practically all modern ones do. Some very old clients don't send it and get the server's default certificate.
What happens if a client doesn't send SNI? The server falls back to its default certificate. If that doesn't match the requested hostname, the client reports a certificate mismatch.
How do I test SNI with openssl or curl?
Run openssl s_client -connect host:443 -servername example.com and inspect the subject and SANs. Compare with the same command without -servername. Use curl --resolve example.com:443:IP https://example.com to test against a specific IP.
How does SNI work for custom domains on a SaaS product? Customers point their hostnames at one shared edge. When a visitor connects, the edge uses the SNI name to pick the certificate for that hostname. With Domainee, SSL is issued on the first request via Let's Encrypt and renewed automatically.
Why does my custom domain show the wrong certificate or fail the TLS handshake?
Common causes: DNS doesn't point at the edge, the client sent no SNI, or a CAA record blocks certificate issuance. Check monitorStatus for dns_not_resolving, dns_incorrect, pending_ssl or ssl_failed. Then test with openssl s_client -servername.
Check your hostname
Run your hostname through the free SSL certificate checker. No key needed.
Building custom domains into a SaaS? Create your first domain with one API call. The free tier covers 20 domains, forever.