Vaultools
Menu

SAN (Subject Alternative Name)

The Subject Alternative Name is an X.509 certificate extension that lists every identity the certificate is valid for, such as DNS names, IP addresses, email addresses and URIs. Modern clients check the hostname against it and ignore the common name.

Why it exists

A single certificate often needs to cover more than one name: example.com, www.example.com, api.example.com. The subject’s common name (CN) can only hold one value. The SAN extension is a list, so one certificate can cover many hostnames.

Browsers and other TLS clients now match the hostname you asked for against the SAN list only. Chrome stopped falling back to the common name in 2017, and a certificate that carries its hostname only in the CN is rejected. The modern service-identity rules in RFC 9525 say the same.

Entry types

TypeExample
DNS nameexample.com, *.example.com
IP address192.0.2.10, 2001:db8::1
Email address[email protected]
URIhttps://example.com/

For websites, DNS names and IP addresses are what matter. Email and URI entries appear mostly in S/MIME and service-to-service certificates.

Wildcards

A wildcard covers exactly one label, and only in the leftmost position.

Adding a SAN to a certificate you create

With OpenSSL, for a self-signed development certificate:

openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem \
  -days 30 -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

Common pitfalls

References

Ads on this page

Non-personalized ads help keep Vaultools free — Google decides where they appear on the page.

Go Pro to remove them →