# Wildcard certificates explained (*.example.com)

> A wildcard certificate such as "*.example.com" secures every single-level subdomain of a domain with one certificate.

URL: https://levelrail.com/learn/domains-https/wildcard-certificates-explained/
Updated: 2026-11-27

A wildcard certificate such as `*.example.com` covers any single subdomain (`app.example.com`, `api.example.com`) but not `example.com` itself and not two-level names like `a.b.example.com`. Let's Encrypt issues wildcards only after a [DNS-01](https://levelrail.com/learn/glossary/#acme)) check, where you publish a TXT record.

## A short history

Wildcard names are part of the certificate standards, but Let's Encrypt did not issue them until March 2018, when its newer ACME protocol version launched. Before that, free wildcards were not available from it, so many people ran one certificate per name.

## How it works

A certificate lists the names it is valid for in its Subject Alternative Name (SAN) field. A browser compares the name in the address bar with that list. A wildcard entry `*.example.com` matches exactly one label in the leftmost position. So `app.example.com` matches, but `example.com` (no label) does not, and `a.b.example.com` (two labels) does not. Wildcards cannot be nested, so `*.*.example.com` is not valid.

Let's Encrypt must see that you control the domain. For a normal name it can fetch a token over HTTP on port 80 (HTTP-01). For a wildcard that is not enough, because proving you control one web server does not prove you control every possible subdomain. So Let's Encrypt issues wildcards only through the DNS-01 challenge: your client creates a TXT record named `_acme-challenge.example.com` with a value the CA gave it, and the CA looks it up in DNS. That proves control of the whole zone.

Doing that by hand every 90 days is impractical, so clients use your DNS provider's API to create and remove the TXT record. The same API key can edit your whole zone, which is why the next section matters.

## What it covers

`*.example.com` matches one label in front of the domain:

- `app.example.com` is covered.
- `api.example.com` is covered.
- `example.com` is not covered. List it as its own name.
- `a.b.example.com` is not covered (two levels).

## Trade-offs

- **Good:** one certificate for many subdomains, and new subdomains work with no new request. It also keeps private subdomain names out of public certificate logs.
- **Cost:** your server needs a DNS API key, which is powerful. Store it carefully and scope it to the one zone.
- **Cost:** one private key now protects every subdomain. If it leaks, all of them are exposed.
- **Alternative:** separate certificates per name need no DNS access and limit the damage of one leak.

## Comparing the options

| Option | Names covered | Needs DNS API | Blast radius of a leaked key |
| --- | --- | --- | --- |
| One certificate per name | One | No | One name |
| Multi-name certificate | A fixed list | No | The listed names |
| Wildcard | Any single-label subdomain | Yes, for DNS-01 | Every subdomain |

## Common misconceptions

- A wildcard does not cover the bare domain, so list both names.
- A wildcard does not cover deeper names such as `a.b.example.com`.
- A wildcard is not an access control. Unknown names still get a valid certificate if your server answers for them.

## When not to use a wildcard

Skip it if you have one or two names, if your DNS host has no API and you cannot delegate the challenge, or if one compromised server should not be able to impersonate every subdomain.

## Check it worked

See it for yourself on any server that has a wildcard certificate:

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

`s_client` connects and prints the certificate, `-servername` sends the name for SNI, and `x509 -ext subjectAltName` prints the name list. What you should see: a `DNS:*.example.com` entry and usually `DNS:example.com`. Compare it with the name you visited. The `-ext` option needs OpenSSL 1.1.1 or newer. For the full walkthrough see [Inspect a TLS certificate with OpenSSL](https://levelrail.com/learn/domains-https/inspect-a-tls-certificate-with-openssl/)).

To request one yourself with certbot, with the names listed explicitly:

```bash
sudo certbot certonly --manual --preferred-challenges dns -d example.com -d '*.example.com'
```

Certbot prints the TXT record to create. Check it before you continue with `dig +short TXT _acme-challenge.example.com`. Manual mode does not renew automatically. For renewal, use a certbot DNS plugin for your provider. Add `--staging` first to practice.

## Edge cases and gotchas

- **The bare domain is not included.** `*.example.com` does not cover `example.com`. Request both names.
- **Two levels need their own wildcard.** `a.b.example.com` needs `*.b.example.com` or its own name.
- **Both names share one TXT name.** Requesting `example.com` and `*.example.com` together can require two TXT values at `_acme-challenge.example.com`. Some DNS panels handle several values on one name, and some overwrite the first. Check with `dig` that both exist.
- **DNS propagation.** A slow provider may not show the TXT record before the CA checks. Increase your client's propagation wait setting.
- **A specific certificate can be preferred.** A server with both a wildcard and a certificate for one exact name picks per its config, and an exact-name certificate is not always chosen the way you expect. Check which one is served with `openssl s_client`.
- **A wildcard hides nothing about the zone itself.** Anyone can still try names, and unknown names under it still get a valid certificate if your server answers for them. Do not treat a wildcard as access control.
- **A CNAME for `_acme-challenge` delegation.** You can delegate the challenge record to another zone with a CNAME if your DNS host lacks an API. Do it only if you understand who then controls that zone.

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| DNS challenge fails, the CA says the TXT record was not found | Record not visible yet, or wrong name | Check `dig +short TXT _acme-challenge.example.com`, wait longer |
| API permission or authentication error | The DNS token cannot edit the zone | Give the token rights to that zone only |
| Browser warns on `a.b.example.com` | Two levels are not covered | Add `*.b.example.com` or the exact name |
| `NET::ERR_CERT_COMMON_NAME_INVALID` on the bare domain | Bare domain not listed on the certificate | Reissue with `-d example.com -d '*.example.com'` |
| Wildcard request refused over HTTP | HTTP-01 cannot issue wildcards | Use `--preferred-challenges dns` with a DNS plugin |
| Renewal fails months later | Manual mode, or the token was rotated | Use a DNS plugin and update the saved credentials |
| Rate limit message | Too many recent requests | Wait, and test with `--staging` |
| Certificate is issued but the bare domain shows an error | The bare domain was not listed | Request `example.com` and `*.example.com` together |
| Old and new certificate names mix up | Two lineages exist in `/etc/letsencrypt` | Run `sudo certbot certificates` and delete the one you do not use |

## Real-world scenario

Kai hosts a dozen internal tools at names like `grafana.example.com`, `git.example.com` and a few more he adds every month. Separate certificates mean separate renewals and a public record of each name. He decides on a wildcard, using his DNS host's certbot plugin so renewal is automatic.

```bash
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/cf.ini -d example.com -d '*.example.com'
sudo certbot certificates
```

The plugin name depends on the DNS provider, and the token file is readable by root only (`chmod 600`). The listing shows both names on one certificate. A month later he adds `wiki.example.com` and needs no new request. Then a coworker asks why `old.dev.example.com` fails: it has two labels, so he adds `*.dev.example.com` as a second name. The challenge itself is described in [HTTPS and Let's Encrypt](https://levelrail.com/learn/domains-https/https-and-lets-encrypt/)), and the renewal routine in [renew Let's Encrypt certificates](https://levelrail.com/learn/domains-https/renew-lets-encrypt-certificates/)).

## Quick reference

| Name | Covered by `*.example.com` |
| --- | --- |
| `app.example.com` | yes |
| `example.com` | no, list it separately |
| `a.b.example.com` | no, needs `*.b.example.com` |
| `*.*.example.com` | not valid |

Challenge: DNS-01 only, TXT record at `_acme-challenge.example.com`. Practice with `--staging`.

## Security and safety notes

- Treat the DNS API token like a password: scope it to one zone, store it with restricted file permissions, and never commit it.
- Protect the wildcard private key. Anyone who has it can impersonate every subdomain.

## Related lessons

- [HTTPS and Let's Encrypt](https://levelrail.com/learn/domains-https/https-and-lets-encrypt/)): the basics of issuing
- [DNS record types explained](https://levelrail.com/learn/domains-https/dns-record-types-explained/)): the TXT record that proves control
- [Renew Let's Encrypt certificates](https://levelrail.com/learn/domains-https/renew-lets-encrypt-certificates/)): automatic renewals with DNS-01
- [Inspect a TLS certificate with OpenSSL](https://levelrail.com/learn/domains-https/inspect-a-tls-certificate-with-openssl/)): read the names a certificate covers

## Next

Read a certificate yourself with [Inspect a TLS certificate with OpenSSL](https://levelrail.com/learn/domains-https/inspect-a-tls-certificate-with-openssl/)).

## Frequently asked questions

### Does *.example.com cover example.com?

No. The bare domain must be listed as its own name, so request both example.com and *.example.com.

### Can I use a wildcard for a.b.example.com?

Not with *.example.com. That covers one label only. You would need *.b.example.com as its own name on the certificate.

### Can I get a wildcard with the HTTP-01 challenge?

No. Let's Encrypt issues wildcards only through the DNS-01 challenge.

### Is a wildcard certificate the same as one certificate with many names?

No. A multi-name certificate lists each hostname and is visible in public logs. A wildcard matches any single label, so new subdomains work without a new request.


## Sources

- [Let's Encrypt, challenge types](https://letsencrypt.org/docs/challenge-types/)
- [Let's Encrypt FAQ](https://letsencrypt.org/docs/faq/)
