Skip to content

ERR_CERT_COMMON_NAME_INVALID on cPanel — the server is serving the wrong certificate

A site shows ERR_CERT_COMMON_NAME_INVALID or a certificate for a different domain. The certificate is valid but bound to the wrong hostname. Here is why cPanel serves the wrong cert and how to fix it.

ERR_CERT_COMMON_NAME_INVALID (or NET::ERR_CERT_COMMON_NAME_INVALID) means the certificate the browser received is perfectly valid — it just is not for the hostname you asked for. The browser visited example.com and was handed a certificate whose name is something else entirely: the server hostname, another customer’s domain, or a stale cert from before a migration. The certificate is not expired or untrusted; it is bound to the wrong vhost. This is a server-side SSL binding problem, not a problem with the certificate’s validity.

What’s happening

An Apache (or LiteSpeed) server with many HTTPS sites uses SNI (Server Name Indication) so the client tells the server which hostname it wants, and the server returns the certificate bound to that virtual host. When the requested hostname has no SSL host entry, the server falls back to a default certificate — usually the server’s own hostname cert or the first SSL vhost — and the browser, seeing a name mismatch, throws ERR_CERT_COMMON_NAME_INVALID.

On cPanel the usual causes: the domain has no certificate installed for its HTTPS vhost (AutoSSL never issued one, or it was removed), so the server serves the fallback; the domain is being reached over a shared/dedicated IP that hosts a different account whose cert is the default for that IP; www vs. non-www mismatch, where the cert covers one but the visitor used the other; a stale certificate left bound after a domain move or rename; or a client/CDN connecting without SNI (old clients, some health checks) and always getting the IP’s default cert. The fix is to bind the correct certificate to the correct hostname.

How to verify

The decisive check is to ask the server, with SNI, exactly what cert it hands back for the hostname in question:

# What cert does the server return FOR THIS hostname (SNI on)?
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates

# What does it return with NO SNI (the IP's fallback/default cert)?
echo | openssl s_client -connect example.com:443 2>/dev/null \
  | openssl x509 -noout -subject

If the SNI subject is a different domain (or the server hostname), this account has no cert bound for example.com. Confirm what cPanel thinks is installed and on which IP:

# Is an SSL host actually installed for this domain?
whmapi1 installed_hosts | grep -iA3 example.com

# What IP does the domain resolve to, and is it shared?
dig +short example.com
grep -i example.com /etc/userdatadomains   # account + IP mapping

Check the www/non-www coverage and whether a stale cert lingers:

# Does the cert cover both apex and www?
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -ext subjectAltName

# AutoSSL's view of this account's coverage
/usr/local/cpanel/bin/autossl_check_cpuser <cpaneluser>

A mismatched SNI subject is the smoking gun: the right certificate is simply not bound to this vhost.

The fix

  1. Issue or reinstall the certificate for this domain — the most common cause is no cert bound at all. Run AutoSSL for the account (/usr/local/cpanel/bin/autossl_check_cpuser <cpaneluser> or WHM » Manage AutoSSL » Check) so it issues and binds a cert covering the hostname. For a manual cert, install it in WHM » SSL/TLS » Install an SSL Certificate on a Domain and confirm it binds to the right vhost.
  2. Cover both www and non-www — if the cert is valid for example.com but the visitor uses www.example.com (or vice versa), the name mismatches. Ensure both names are on the certificate (AutoSSL normally includes both when DNS for www resolves) and that the www record exists in the zone.
  3. Remove a stale certificate bound to the vhost — after a domain move or rename, an old cert can stay bound. In WHM » SSL/TLS » Manage SSL Hosts, find the entry for the domain, remove the stale certificate, then re-run AutoSSL so the correct one is installed.
  4. Check the IP assignment for shared-IP collisions — on a shared IP without a per-domain cert, the browser gets whichever cert is the IP default. Confirm the domain has its own SSL host (step 1); if the site genuinely needs isolation, assign a dedicated IP in WHM » Change a Site’s IP Address and reinstall the cert there.
  5. Account for clients that do not send SNI — old clients, some uptime monitors, and certain CDN configurations connect without SNI and always receive the IP’s default cert, mismatching every other domain on that IP. Modern browsers all send SNI; if a specific non-browser client trips this, point it at the correct hostname or give the domain a dedicated IP.
  6. Update the certificate hostname after a server rename — if the server’s own hostname changed, its service certificate may not match, surfacing on cpanel./webmail. URLs. Reissue the hostname certificate via WHM » Manage Service SSL Certificates so service subdomains stop mismatching.
  7. Verify behind a CDN/proxy — if Cloudflare or another proxy sits in front, the browser sees the edge certificate; an ERR_CERT_COMMON_NAME_INVALID there is the edge/SSL-mode misconfigured, not the origin. Confirm where the request terminates TLS before chasing the origin cert.
  8. Re-test with SNI after binding — once the correct cert is installed, re-run the openssl s_client -servername check and confirm the subject now matches the hostname, then reload the site. The error clears the instant the right certificate is bound to the right vhost.

The certificate was valid the whole time — it just was not the one this hostname is supposed to present. Binding the right cert to the right vhost is the entire fix. Stack Harbor keeps SSL bindings correct across busy servers under WHM server management — start a conversation when a site serves the wrong certificate.