SSL Certificate Selection Based on Host-Header – Is It Possible?

httpssslssl-certificateweb-hosting

Is it possible for a web server to select an SSL certificate to use based on the host-header of the incoming connection, or is that information that is only available after the SSL connection is established?

That is, can my webserver listed on port 443 and use the foo.com certificate if https://foo.com is requested, and the bar.com certificate if https://bar.com is requested or am I trying to do something impossible because the server has to establish an SSL connection before it knows what the client wants?

Best Answer

Historically, your first statement is accurate. Now, there are multiple options:

  • A wildcard certificate if subdomains within the same domain.
  • A SAN/UCC cert to specify alternative names for the certificate, thus being able to serve multiple certificates.
  • SNI was introduced to establish the SSL connection after the Host header. This has limited support, however, as it is newer.

This has been answered numerous times on ServerFault by myself and others. I'd suggest searching for further details unless you have a specific question.