NET::ERR_CERT_COMMON_NAME_INVALID: name does not match the certificate

The certificate is valid, but issued for a different name. Usually a name is missing from the certificate, or the server delivers another site’s certificate for this address.

What the browser checks

Browsers compare the address with the Subject Alternative Name (SAN) entries in the certificate. The Common Name (CN) has not counted for years; Chrome has ignored it since version 58. A certificate with only a CN and no SAN is therefore valid for no name. Firefox reports the error as SSL_ERROR_BAD_CERT_DOMAIN.

The most common causes

  1. www or bare domain missing. The certificate covers www.example.com, the visitor opens example.com or vice versa.
  2. Wildcard limits. *.example.com covers shop.example.com, but neither example.com itself nor a.b.example.com.
  3. The wrong vhost answers. There is no matching server_name or ServerName for the name. The server then uses the default vhost and its certificate.
  4. DNS points to the wrong server. After a move a record still points to the old host or a CDN address without your certificate.
  5. Access by IP address or internal short name. https://10.0.0.5 or https://intranet only match if exactly that is in the certificate.

Check

The SSL check shows all names in the certificate and marks whether the checked name is among them. On the command line, -servername matters, otherwise you may see a different certificate:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName

Whether DNS points to the right server is shown by the DNS lookup.

Fix

FAQ

Does a certificate for example.com also cover www.example.com?

No, unless both names are in the certificate. Let's Encrypt and most CAs include both if you request them.

Why does openssl show a different certificate than the browser?

Without -servername openssl sends no name (SNI) and gets the server’s default certificate. Browsers always send the name.

Can I get a certificate for an IP address?

From an internal CA, yes. Public certificates for IP addresses are offered by few CAs and usually with a short lifetime. A DNS name is simpler.

Sources and documentation