Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do Common Names (CN) and Subject Alternative Names (SAN) work together?

Assuming the Subject Alternative Name (SAN) property of an SSL certificate contains two DNS names

  1. domain.tld
  2. host.domain.tld

but the Common Name (CN) is set to only one of both: CN=domain.tld.

  • Does this setup have a special meaning, or any [dis]advantages over setting both CNs?
  • What happens on server-side if the other one, host.domain.tld, is being requested?

Specifically, how does OpenSSL 0.9.8b+ handle the given scenario?

like image 734
Jürgen Thelen Avatar asked May 09 '11 10:05

Jürgen Thelen


People also ask

Should cn be included in SAN?

A: Not at all. If there are SANs, then CN can be ignored.

What is common name and Subject Alternative Name?

The common name can only contain up to one entry: either a wildcard or non-wildcard name. It's not possible to specify a list of names covered by an SSL certificate in the common name field. The Subject Alternative Name extension (also called Subject Alternate Name or SAN) was introduced to solve this limitation.

How do subject alternative names work?

The Subject Alternative Name Field ExplainedThe Subject Alternative Name field lets you specify additional host names (sites, IP addresses, common names, etc.) to be protected by a single SSL Certificate, such as a Multi-Domain (SAN) or Extend Validation Multi-Domain Certificate.


Video Answer


1 Answers

This depends on implementation, but the general rule is that the domain is checked against all SANs and the common name. If the domain is found there, then the certificate is ok for connection.

RFC 5280, section 4.1.2.6 says "The subject name MAY be carried in the subject field and/or the subjectAltName extension". This means that the domain name must be checked against both SubjectAltName extension and Subject property (namely it's common name parameter) of the certificate. These two places complement each other, and not duplicate it. And SubjectAltName is a proper place to put additional names, such as www.domain.com or www2.domain.com

Update: as per RFC 6125, published in 2011, the validator must check SAN first, and if SAN exists, then CN should not be checked. Note that RFC 6125 is relatively recent and there still exist certificates and CAs that issue certificates, which include the "main" domain name in CN and alternative domain names in SAN. I.e. by excluding CN from validation if SAN is present, you can deny some otherwise valid certificate.

like image 85
Eugene Mayevski 'Callback Avatar answered Sep 17 '22 23:09

Eugene Mayevski 'Callback