Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I include 'www' in the common name of a SSL cert request? [closed]

Tags:

ssl

I'm about to purchase a SSL certificiate for a small website. Is it best practice to enter 'www.domainName.com' or 'domainName.com' for the common name?

like image 621
DenaliHardtail Avatar asked Mar 29 '13 21:03

DenaliHardtail


People also ask

Should common name include www?

You will only be able to secure the second-level subdomains (sub1.www.example.com, sub2.www.example.com and so on). So, in these certs, the common name should be used without www, unless it is done intentionally and you need to secure sub1.www.example.com, sub2.www.example.com etc.

Do you need separate SSL for WWW?

You don't need a separate SSL for www and non www, although the specifics depend on which certificate type you have: Single domain: secures www and non-www by default. Wildcard: secures www and non-www by default. Multi-domain: need to add separate SANs for www and non-www.

What should certificate common name?

The common name is the domain name you wish to secure with your certificate. If you are creating a single domain certificate, entering the common name is straightforward: it is the single domain you wish to secure. Don't forget to include the subdomain if your single address includes a subdomain.

Is common name mandatory in SSL certificate?

While generating a CSR, you will be required to enter information in the Common Name field. Certificates are specific to the Common Name that they have been issued to at the Host level. The Common Name must be the same as the Web address you access when connecting to a secure site.


1 Answers

Make sure you use the subjectAltName field, and include all variations of the hostname(s) you want to use, or a wildcard if you aren't sure what all the variations will be. The common name (CN) is only used as a backup. See RFC 2818 for more details:

###3.1. Server Identity

In general, HTTP/TLS requests are generated by dereferencing a URI. As a consequence, the hostname for the server is known to the client. If the hostname is available, the client MUST check it against the server's identity as presented in the server's Certificate message, in order to prevent man-in-the-middle attacks.

If the client has external information as to the expected identity of the server, the hostname check MAY be omitted. (For instance, a client may be connecting to a machine whose address and hostname are dynamic but the client knows the certificate that the server will present.) In such cases, it is important to narrow the scope of acceptable certificates as much as possible in order to prevent man in the middle attacks. In special cases, it may be appropriate for the client to simply ignore the server's identity, but it must be understood that this leaves the connection open to active attack.

If a subjectAltName extension of type dNSName is present, that MUST be used as the identity. Otherwise, the (most specific) Common Name field in the Subject field of the certificate MUST be used. Although the use of the Common Name is existing practice, it is deprecated and Certification Authorities are encouraged to use the dNSName instead.

Matching is performed using the matching rules specified by [RFC2459]. If more than one identity of a given type is present in the certificate (e.g., more than one dNSName name, a match in any one of the set is considered acceptable.) Names may contain the wildcard character * which is considered to match any single domain name component or component fragment. E.g., *.a.com matches foo.a.com but not bar.foo.a.com. f*.com matches foo.com but not bar.com.

In some cases, the URI is specified as an IP address rather than a hostname. In this case, the iPAddress subjectAltName must be present in the certificate and must exactly match the IP in the URI.

If the hostname does not match the identity in the certificate, user oriented clients MUST either notify the user (clients MAY give the user the opportunity to continue with the connection in any case) or terminate the connection with a bad certificate error. Automated clients MUST log the error to an appropriate audit log (if available) and SHOULD terminate the connection (with a bad certificate error). Automated clients MAY provide a configuration setting that disables this check, but MUST provide a setting which enables it.

Note that in many cases the URI itself comes from an untrusted source. The above-described check provides no protection against attacks where this source is compromised. For example, if the URI was obtained by clicking on an HTML page which was itself obtained without using HTTP/TLS, a man in the middle could have replaced the URI. In order to prevent this form of attack, users should carefully examine the certificate presented by the server to determine if it meets their expectations.

like image 84
mpontillo Avatar answered Sep 20 '22 20:09

mpontillo