CertNudge

Guides

Fixing ERR_CERT_COMMON_NAME_INVALID

See which names a certificate covers, why www or a subdomain is missing, and how to add it with certbot.

2 min read · Updated November 2026

Chrome says NET::ERR_CERT_COMMON_NAME_INVALID, Firefox says SSL_ERROR_BAD_CERT_DOMAIN, curl says no alternative certificate subject name matches. The certificate is valid, just not for the name you typed.

See which names the certificate covers

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

Only the Subject Alternative Name list counts. Browsers ignore the common name in the subject. If the name you visit isn't in that list, you get the error.

The usual causes

  • www is missing. The certificate covers example.com but not www.example.com, or the other way round.
  • Wildcards cover one level. *.example.com covers shop.example.com, but not example.com and not eu.shop.example.com.
  • The wrong site answers. The server has several sites, and the one you asked for isn't set up for HTTPS. nginx then serves the default_server certificate, which belongs to another site.
  • DNS points somewhere else. After a move, the old server or a CDN still answers with its own certificate.

Check which certificate is the default

openssl sends the host name (SNI) on its own. To see what clients that don't send it get:

echo | openssl s_client -connect example.com:443 -noservername 2>/dev/null \
  | openssl x509 -noout -subject

If this shows another site, that site is the default. Make sure every name has its own server block with listen 443 ssl, or the right certificate on the default one.

Add the missing name

With certbot, list every name the certificate should cover. It replaces the certificate with one that has all of them:

sudo certbot certonly --cert-name example.com -d example.com -d www.example.com
sudo systemctl reload nginx

Then run the first check again and make sure the new name is in the list.

After it's fixed

Put each name you serve into your monitoring, not only the main one. A www or mail name that falls off the certificate at the next renewal looks fine from the main domain.