|
Botan 3.13.0
Crypto and TLS for C&
|
#include <dns_name.h>
Public Member Functions | |
| bool | is_wildcard () const |
| bool | matches_wildcard (std::string_view wildcard) const |
| const std::string & | name () const |
| auto | operator<=> (const DNSName &) const =default |
| bool | operator== (const DNSName &) const =default |
| const std::string & | to_string () const |
Static Public Member Functions | |
| static std::optional< DNSName > | from_san_string (std::string_view name) |
| static std::optional< DNSName > | from_string (std::string_view name) |
| static bool | host_wildcard_match (std::string_view issued, std::string_view host) |
A DNS name (host name or wildcard pattern) in canonical form.
Construction validates that the input conforms to the Preferred Name Syntax (RFC 1035 / RFC 1123 LDH labels, length limits, no leading or trailing dot). Entirely numeric names ("1.2.3.4") are rejected. The stored form is lowercased ASCII.
Definition at line 25 of file dns_name.h.
|
static |
Like from_string, but additionally accepts the RFC 6125 6.4.3 wildcard form: a single "*" anywhere within the leftmost label of an otherwise-valid DNS name (e.g. "*.example.com", "foo*.example.com"). Shapes that could never produce a match - multiple "*" ("*.*.example.com"), "*" outside the leftmost label ("foo.*.example.com"), or patterns with fewer than three labels ("*", "*.com") - are rejected, as are wildcards embedded within an IDNA A-label ("xn--f*.example.com"). Intended for parsing X.509 SAN dnsName entries.
Definition at line 149 of file dns_name.cpp.
References name().
Referenced by Botan::AlternativeName::add_dns(), Botan::NameConstraints::is_excluded(), Botan::NameConstraints::is_permitted(), Botan::GeneralName::matches(), and Botan::X509_Certificate::matches_dns_name().
|
static |
Parse and canonicalize a literal hostname. Returns nullopt if the input is not a valid DNS name per RFC 1035 / 1123, or if it contains a "*" label (use from_san_string for that).
Definition at line 136 of file dns_name.cpp.
References name().
Referenced by Botan::URI::Authority::from_string(), Botan::TLS::Server_Name_Indicator::hostname_acceptable_for_sni(), and Botan::X509_Certificate::matches_dns_name().
|
static |
Test if the issued name (which might be a wildcard pattern) can match the host, which should be a complete and valid DNS name.
Returns false if either the pattern or the host seem invalid
Definition at line 191 of file dns_name.cpp.
Referenced by matches_wildcard(), and operator==().
|
inline |
True if this name is a wildcard pattern: a single "*" somewhere in the leftmost label, per RFC 6125 6.4.3 (which permits in-label partial wildcards like "foo*.example.com" as well as the complete-leftmost-label "*.example.com" form). Shapes outside this form - multiple "*" or "*" not in the leftmost label - are rejected at construction by from_san_string, so any stored "*" is already in the leftmost label.
TODO(Botan4) when RFC 9525 wildcards are used, this fn can change to just looking at the first character of m_name.
Definition at line 71 of file dns_name.h.
| bool Botan::DNSName::matches_wildcard | ( | std::string_view | wildcard | ) | const |
Test whether this name matches a wildcard pattern (e.g. "*.example.com"). The wildcard label must be the leftmost label. Comparison is case-insensitive.
Definition at line 186 of file dns_name.cpp.
References host_wildcard_match().
Referenced by Botan::X509_Certificate::matches_dns_name().
|
inline |
Access the canonicalized name
Definition at line 57 of file dns_name.h.
Referenced by from_san_string(), and from_string().
|
default |
Order two names by their canonicalized form
|
default |
Compare two names by their canonicalized form
References host_wildcard_match().
|
inline |
Access the canonicalized name
Definition at line 51 of file dns_name.h.
Referenced by Botan::GeneralName::matches_dns(), and Botan::GeneralName::matches_email().