How to fix a certificate that does not cover the hostname
Get a certificate that names every hostname the site answers on, and make the server send it for each of them.
Last reviewed
Why it matters
Browsers accept a certificate only if one of its names matches the address being visited, and show a full-page security warning otherwise. The usual causes are a name never added to the certificate, such as www or a new subdomain, or a server sending its default certificate because no site matches the name.
How to fix it
See which names the certificate covers, for both example.com and www.example.com:
openssl s_client -connect www.example.com:443 -servername www.example.com </dev/null 2>/dev/null | openssl x509 -noout -ext subjectAltName
A wildcard such as *.example.com covers exactly one label: not example.com itself, and not a.b.example.com. Behind a CDN this shows the CDN's certificate; to see the origin's, connect to 203.0.113.10:443 with the same -servername.
Replace the highlighted values: example.com with your domain, www.example.com with the site's hostname, 203.0.113.10 with your origin server's IP address, example.com with the certificate's name, as `certbot certificates` shows it.
nginx
- Put every name in
server_namefor thelisten 443 sslblock; when none matches, nginx sends the default server's certificate:
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
- Get a certificate listing every name, one
-deach. Each name's DNS must already point at this server, with the site reachable on port 80:
sudo certbot --nginx -d example.com -d www.example.com
- To change an existing certificate's names, list all the names to keep:
--cert-namereplaces the whole set.
sudo certbot certificates
sudo certbot certonly --cert-name example.com -d example.com,www.example.com
- Test and reload:
sudo nginx -t && sudo systemctl reload nginx
Sources: nginx: HTTPS servers, certbot user guide.
Apache
- In the
<VirtualHost *:443>block setServerName example.comandServerAlias www.example.com. When nothing matches, Apache uses the first virtual host listed for that address and port, with its certificate. - Issue a certificate for both names:
sudo certbot --apache -d example.com -d www.example.com
- Run
apachectl configtest, then reload.
Sources: name-based virtual hosts, SSL how-to, certbot user guide.
Caddy
Caddy gets certificates only for the hostnames in its site addresses, so every name must appear in one. The names' DNS must point at the server, ports 80 and 443 must be reachable, and the data directory must persist:
www.example.com {
redir https://example.com{uri}
}
example.com {
# the site
}
Or serve both from one block, example.com, www.example.com { … }. Reload Caddy afterwards.
Sources: automatic HTTPS, Caddyfile patterns.
Cloudflare
- Cloudflare's certificate is served only for proxied records. For a DNS-only record visitors see the origin's certificate, so fix it at the origin.
- Universal SSL covers the apex and first-level subdomains (
example.com,www.example.com), not deeper names such asdev.www.example.com. For those, use Advanced Certificate Manager (Total TLS, or an advanced certificate for the names) or upload a custom certificate. - Check the status under SSL/TLS > Edge Certificates.
- With SSL mode Full (strict), the origin's certificate must also name the hostname, be in date, and come from a public authority or Cloudflare's Origin CA, or visitors get error 526.
Sources: Universal SSL, its limitations, Total TLS, Full (strict).
Shopify
Shopify issues free certificates for connected domains automatically, within 48 hours. If a name is missing or pending:
- In Settings > Domains, check the domain shows Connected.
- Check the DNS records: A
@to23.227.38.65, AAAA@to2620:0127:f00f:5::, CNAMEwwwtoshops.myshopify.com.(other subdomains need only that CNAME). Keep exactly one A and one AAAA record, and no wildcard pointing at Shopify. - On Cloudflare DNS, set every record pointing at Shopify to DNS only: Shopify does not support the proxy.
- If you have CAA records, allow
letsencrypt.org,pki.googandssl.com. - Turn off DNSSEC at your DNS provider if it is on. If the certificate is still pending after 48 hours, contact Shopify Support.
Sources: Shopify: secure connections, troubleshoot domains, connect a domain manually.
Vercel
Vercel issues a certificate for every domain added to the project, and none for a name that is not.
- Project > Settings > Domains > Add Existing, and add both
example.comandwww.example.com. - Set the redirect: Edit the domain and pick a target under Redirect to.
- Configure DNS as the dashboard shows, so requests reach Vercel; if you have CAA records, allow Let's Encrypt.
- Confirm with the domain's status in Settings > Domains, or
vercel certs list.
Sources: add a domain, redirecting, SSL.
Netlify
- Adding either the apex or
wwwadds both, so point both at Netlify: the apex with an ALIAS, ANAME or flattened CNAME toapex-loadbalancer.netlify.com(or an A record to75.2.60.5), andwwwwith a CNAME to the site'snetlify.appaddress. - Add any other name under Domain management > Production domains > Add domain alias. Aliases join the certificate only if their DNS already points at Netlify when it is issued.
- Provisioning is blocked by more than one A record on the apex, leftover AAAA records, DNSSEC, or CAA records that do not allow Let's Encrypt.
- Check the status under Domain management > HTTPS.
Sources: HTTPS on Netlify, troubleshooting, external DNS, domain aliases.
Check that it worked
- Run the
openssl … -ext subjectAltNamecommand again for every hostname you serve: each must be listed, exactly or under a one-label wildcard. - Open
https://www.example.com/in a private window and confirm there is no warning. - Run the Owl Keeper Certificate check again.
Test it now with the free SSL certificate checker. No account needed.
What can go wrong
- Pointing DNS somewhere new to validate a name moves real traffic. Check what answers on that name now (mail, an old app, another service) before you change it, and the same before switching a Cloudflare record between proxied and DNS only.
certbot --cert-namewith a shorter list removes names, which stop being covered at the next reload.- Changing
server_name,ServerNameor the order of virtual hosts can change which site unmatched hostnames receive. - CAA and DNSSEC changes affect every service on the domain.