You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The enforce_hostnames=false role parameter does not allow underscores in DNS SANs, contradicting the official PKI API documentation which states:
enforce_hostnames (bool: true) - Specifies if only valid host names are allowed for CNs, DNS SANs, and the host part of email addresses.
The documentation implies that setting enforce_hostnames=false should relax hostname validation (including the "no underscores" rule) for DNS SANs. In practice, DNS SANs containing underscores are always rejected regardless of this setting:
In v1.20.3 (and earlier): the invalid SAN is silently dropped from the issued certificate with no warning or error.
In the current main branch: the request errors out with "subject alternate name <name> is not a valid DNS name and cannot be included as a SAN".
Neither behavior matches the documentation's promise.
Root cause: the hostnameRegex in issue_common.go does not allow underscores, and the regex check at SAN extraction is independent of role.EnforceHostnames. The EnforceHostnames flag is only consulted later in ValidateNames, which is after the underscore SAN has already been stripped or rejected.
X509v3 Subject Alternative Name:
DNS:test.example.com, DNS:with-hyphen.example.com
Expected behavior
With enforce_hostnames=false (and allow_any_name=true, allow_wildcard_certificates=true), DNS SANs containing underscores should be accepted and included in the issued certificate, per the documentation.
Alternatively, if this is intentional, the documentation should be updated to clarify that hostname format validation (specifically the hostnameRegex check at SAN extraction) is always enforced on DNS SANs regardless of enforce_hostnames.
Environment:
Vault Server Version (retrieve with vault status): Vault v1.20.3
Vault CLI Version (retrieve with vault version): v1.20.3
The current main branch changed the behavior from silent drop to explicit error (see issue_common.go), but the core issue — that enforce_hostnames=false does not actually relax DNS SAN hostname validation as documented — remains unaddressed.
Workaround: names with underscores can be placed in the CN (which is then automatically copied to SANs only if it's a valid hostname, so underscore-containing CNs don't appear in SANs either), or passed via uri_sans with a URI scheme prefix.
Describe the bug
The
enforce_hostnames=falserole parameter does not allow underscores in DNS SANs, contradicting the official PKI API documentation which states:"subject alternate name <name> is not a valid DNS name and cannot be included as a SAN".Neither behavior matches the documentation's promise.
Root cause: the
hostnameRegexinissue_common.godoes not allow underscores, and the regex check at SAN extraction is independent ofrole.EnforceHostnames. TheEnforceHostnamesflag is only consulted later inValidateNames, which is after the underscore SAN has already been stripped or rejected.To Reproduce
Steps to reproduce the behavior:
alt_names:output:
Expected behavior
With
enforce_hostnames=false(andallow_any_name=true,allow_wildcard_certificates=true), DNS SANs containing underscores should be accepted and included in the issued certificate, per the documentation.Alternatively, if this is intentional, the documentation should be updated to clarify that hostname format validation (specifically the
hostnameRegexcheck at SAN extraction) is always enforced on DNS SANs regardless ofenforce_hostnames.Environment:
vault status): Vault v1.20.3vault version): v1.20.3Additional context
Underscores in the CN work correctly (fixed in PKI Secrets Engine: underscores not permitted in common_name value #3876 for Vault 0.9.4), but that fix was not extended to DNS SANs.
The current main branch changed the behavior from silent drop to explicit error (see issue_common.go), but the core issue — that enforce_hostnames=false does not actually relax DNS SAN hostname validation as documented — remains unaddressed.
Workaround: names with underscores can be placed in the CN (which is then automatically copied to SANs only if it's a valid hostname, so underscore-containing CNs don't appear in SANs either), or passed via uri_sans with a URI scheme prefix.