Add support for matching certificate hostnames.
Review Request #15017 — Created April 16, 2026 and updated
This introduces
Certificate.matches_hostname(), which takes a hostname
and matches it against the hostnames and/or wildcard hostnames stored in
the certificate (as both the primary hostname and in the SAN fields).It wraps a utility function,
get_cert_hostname_matches(), which can be
used without aCertificateinstance.Wildcard matching takes care to only match the first label in a hostname
(such as*.example.com) and to avoid matching bare hostnames. It does
not support partial wildcards, such asfoo*,*bar, orfoo*bar, as
these are largely unsupported by browsers, servers, and Certificate
Authorities these days (Chrome treats them as a security issue).
Unit tests pass.
| Summary | ID |
|---|---|
| 8db5a6fef00d888a815fe6768ea804686cdff372 |