DEV Community

yutianle
yutianle

Posted on

A wildcard certificate covers one left-most label, not every subdomain

A wildcard certificate covers one left-most label, not every subdomain

A certificate for *.example.com looks like a convenient way to cover a large service estate. Its scope is narrower than many teams assume. RFC 9525 defines service identity in TLS and states that the only legal place for a wildcard is the complete left-most label in a domain name. The certificate's server identity must appear in subjectAltName; the common name is not a valid replacement.

A wildcard therefore does not automatically cover example.com, api.prod.example.com, or an arbitrary number of labels. The client compares a reference identity, derived from the service it intends to reach, with the presented identifier. The application must obtain that reference identity correctly. A web client connecting to api.example.com is checking a different name from an SMTP or API client that follows a service-discovery record unless the application deliberately defines the mapping.

The protocol rule is one part of the identity decision. A valid certificate does not show that the service belongs to the expected tenant, that the application is the intended one, or that the endpoint should be reached. Those conclusions belong to configuration, DNS, authorization, and the client application.

Inventory more than the wildcard

Inventory every SAN in a wildcard certificate and the services that present it. A multi-tenant product may use a shared wildcard across environments, but a certificate copied to a staging host can expose a production name to the wrong deployment. A certificate whose SANs are too broad also makes revocation and rotation affect more services.

Key custody and issuance policy matter as much as the name pattern. The private key for a wildcard can impersonate any matching single-label hostname. Keep it in a controlled secret store, limit who can use it, rotate it on a schedule that accounts for deployment lead time, and record every certificate issuance. Do not let a tenant or application operator obtain a wildcard for a domain they do not own.

Test the exact validation behavior used by each client library. Some clients accept the common name for legacy compatibility, while others follow the modern SAN-only rule. A library that normalizes Unicode or trailing dots differently can change the reference identity. Those implementation details should be covered by a certificate test suite rather than discovered during an outage or an incident.

A wildcard is a certificate name constraint. It is not a wildcard permission grant. The service, hostname, tenant, and application still need their own authorization checks.

References

Top comments (0)