Wildcard SSL certificates: what they cover, what they don't, and how to renew them

A wildcard certificate covers one level of subdomains, not the bare domain or deeper names. How matching works, how to issue and renew one, and the risks to know.

· 6 min read · By the Spot Downtime team

A wildcard certificate, such as *.example.com, lets one certificate secure many subdomains. It is convenient, and it is also the source of a steady stream of "name mismatch" errors, because people assume it covers more than it does.

This post explains exactly what a wildcard matches, how to get and renew one, and what to watch for once it is deployed on many servers.

What a wildcard certificate matches

The asterisk stands for exactly one DNS label, the part between two dots. The rules are narrower than most people expect:

  • *.example.com matches www.example.com, api.example.com and shop.example.com.
  • It does not match the bare domain example.com. The certificate must list that name separately.
  • It does not match a.b.example.com. Wildcards do not span two levels. You would need *.b.example.com as well.
  • It does not match *.example.org or any other domain. Each domain needs its own entry.

In practice a wildcard certificate is issued with two names in its Subject Alternative Name (SAN) list: example.com and *.example.com. Browsers match the hostname against the SAN list, not the old Common Name field, which is why the ERR_CERT_COMMON_NAME_INVALID error appears when the name you visit is not in it.

Check what a certificate really covers

Read the SAN list straight from the server instead of guessing:

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

The output lists every name the certificate is valid for and its expiry date. The SSL checkershows the same information without a terminal.

How to get a wildcard certificate

Public certificate authorities issue wildcards only after you prove control of the domain through DNS. The usual method is the ACME dns-01 challenge: your client creates a TXT record at _acme-challenge.example.com, and the CA looks it up. The simpler http-01 challenge cannot validate a wildcard.

With certbot and a DNS plugin, for example Cloudflare:

bash
sudo certbot certonly \
  --dns-cloudflare \
  --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \
  -d example.com -d "*.example.com"

Other ACME clients (acme.sh, lego, cert-manager in Kubernetes) work the same way: they need an API token that can edit DNS records for the zone. Give that token the smallest scope your DNS provider allows, ideally one zone, because it can change your DNS.

Why wildcard renewals fail

Renewal runs the same DNS challenge again, so anything that breaks it breaks renewal. The common causes:

  • The DNS API token expired, was rotated or lost its permission.
  • The DNS provider changed or you moved nameservers and the client still talks to the old provider.
  • A leftover _acme-challenge CNAME or TXT record conflicts with the new one.
  • Propagation is slow, so the CA checks before the TXT record is visible.
  • The renewal job runs on one server, and that server was replaced.

These overlap with the causes in Let's Encrypt renewal failures and cert-manager renewal failures. Test renewal without waiting for the deadline:

bash
sudo certbot renew --dry-run

The trade-offs of using one wildcard everywhere

One key protects many hosts

The same private key sits on every server that uses the certificate. If one of them is compromised, an attacker can impersonate any subdomain, including ones that were never on that server. Keep the key out of staging machines and shared build systems, or use separate certificates for sensitive hosts such as login.example.com or pay.example.com.

Renewal has to reach every server

A wildcard that renews on one machine must then be copied to every other place it is used: load balancers, a CDN, a mail server, a staging cluster. When one of those copies is missed, it is the one that expires. The certificate is valid, but that endpoint is serving an old copy.

It hides subdomains from certificate logs

Public CAs log every certificate to Certificate Transparency logs. A wildcard does not reveal individual subdomain names in the logs, which some teams like. The downside is that you lose a signal: with per-host certificates, an unexpected issuance for one name is easy to notice. See monitoring Certificate Transparency logs.

Wildcard or individual certificates?

Use a wildcard when you create subdomains often, such as one per customer, or when you have many internal hosts. Use individual certificates when you have a handful of public hostnames and automated issuance, since each key stays on one server and a failure affects one name.

Monitor every endpoint, not just one

The failure mode for wildcards is a stale copy on one host, so checking the main site is not enough. Add an HTTPS monitor for each hostname or load balancer that serves the certificate. Spot Downtime reads the certificate expiry from every HTTPS check and sends warnings 14, 7 and 1 day before it lapses, and an invalid or mismatched certificate fails the check immediately. See SSL monitoring for details, and choosing alert lead times if you want to think through how early to be warned.

SSL checkerEnter any hostname to see its certificate names, issuer and expiry date.

Checklist

  • List both example.com and *.example.com on the certificate.
  • Remember a wildcard covers one level only.
  • Renew with the DNS challenge and run renew --dry-run after any DNS change.
  • Scope the DNS API token to the one zone and store it securely.
  • Monitor each hostname that serves the certificate, including load balancers and CDNs.

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading