Could someone explain me the difference between these certificates in a simplified way? I read some articles but it sounds like they do the same job, namely encrypting many domains with one certificate.

  • 11
    Well, first, there is no such thing as an "SNI" SSL certificate. – Michael Hampton Oct 9 '16 at 10:12
up vote 32 down vote accepted

SAN (Subject Alternative Name) is part of the X509 certificate spec, where the certificate has a field with a list of alternative names that are also valid for the subject (in addition to the single Common Name / CN). This field and wildcard names are essentially the two ways of using one certificate for multiple names.

SNI (Server Name Indication) is a TLS protocol extension that is sort of a TLS protocol equivalent of the HTTP Host-header. When a client sends this, it allows the server to pick the proper certificate to present to the client without having the limitation of using separate IP addresses on the server side (much like how the HTTP Host header is heavily used for plain HTTP).

Do note that SNI is not something that is reflected in the certificate and it actually achieves kind of the opposite of what the question asks for; it simplifies having many certificates, not using one certificate for many things.

On the other hand, it depends heavily on the situation which path is actually preferable. As an example, what the question asks for is almost assuredly not what you actually want if you need certificates for different entities.

  • 2
    It's worth noting that CN has been deprecated for a long time, if a name is in the CN but not SAN (or if a cert doesn't have a SAN field) a lot of clients will get mad at you. – coderanger Oct 10 '16 at 7:55
  • @coderanger If there is SAN field, the CN field is ignored by most clients. If there is no SAN field, the CN field works with most clients (and if they get mad at me it doesn't show). – kubanczyk Oct 10 '16 at 14:08
  • They're judging you silently. – womble Oct 5 '17 at 5:27
  • is SNI something similar to virtual hosts where a server with say one IP address holds several hosts defined in the HTTP config? (some sort of multiplexing: using one IP for several certs instead of each cert with a different IP, where IPv4 are a scarce resource these days) ? – Fernando Gabrieli Jun 30 at 22:48
  • 1
    @FernandoGabrieli Yes, it enables the same kind of name-based setup on the TLS level. – Håkan Lindqvist Jul 1 at 12:50

SAN stands for Subject Alternative Name, and it's an x509 certificate property, and SNI is a feature that the SSL/TLS client can support, thus a totally different entity.

Using a certificate with SAN you can host multiple HTTPS-enabled sites on one IP address even if the client doesn't support the SNI. In this case you hold one certificate for all of your sites, and such certificate must contain all of the site names (ServerNames or ServerAliases in the apache coordinates, or server_name in nginx) as it's SANs. This is a subset of a legacy approach, the one that did extend the "one HTTPS-enabled site on each separate IP address". Currently only large CDNs stick with SAN.

Using SNI you can also host multiple HTTPS-enabled sites on one IP, you hold a separate x509 certificate for each site and neither of these mentions other site names in their SAN property, but TLS clients (i.e. browsers and console clients such as wget or curl) must support SNI. This is a modern approach, since the last OS not supporting SNI out-of-the-box was Windows XP with IE 6.x, if I remember correctly. Nowadays you can see the SAN property if you purchase the wildcard certificate - for example such a certificate for *.foobar.com will contain a Common Name of *.foobar.com and a SAN of foobar.com.

  • 1
    Technically, I don't believe that an SSL client can support SNI (to my knowledge it's a TLS extension that has never appeared in SSL). – Håkan Lindqvist Oct 9 '16 at 11:21
  • 2
    Both SAN and SNI require client support. However since SAN has been around for a lot longer, it is more widely supported. – kasperd Oct 9 '16 at 12:21

This mixes two parts of the certificate process.

A SAN is a Subject Alternative Name. It is a way to create one certificate for multiple domains. You simply add the other domains you want a certificate for to the SAN field in the certificate. The browser will then accept the validity on these domains as well.

SNI is Server Name Indication and is part of SSL. It allows you to host multiple SSL sites on a single IP because the desired server name is sent with the SSL handshake and the server can choose the correct certificate for the answer.

Here a (possibly) more human readable answer:

SNI is conducted on the client side and tells TLS stack "I want to talk to a server whose name is [Server X]". Server sees this [Server X] string and replies with an appropriate certificate. One practical example is when a single server needs to serve traffic for multiple domains. It is also useful if client used an IP (to avoid DNS lookup delays) but certificate CN does not mention the IP.

SAN is a list of "Also Known As" in certificates. This way server may use a single certificate for many names. One can add many domains to the same certificate and even a list of IPs.

As you can see, things overlap. Choosing between one or both depends where one has control over. Some clients might not recognize names in SAN and the only way to address that is through providing appropriate certificate based on SNI. There are scenarios which server provides API for a single certificate or client does not send SNI. For these cases, SAN is the only way out.

My company makes use of both. They provide flexibility and make backward and forward compatibility easier.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.