Skip to content

pki: honour enforce_hostnames=false for DNS SAN underscore characters#31928

Open
SAY-5 wants to merge 3 commits into
hashicorp:mainfrom
SAY-5:fix/pki-enforce-hostnames-underscore-san-31925
Open

pki: honour enforce_hostnames=false for DNS SAN underscore characters#31928
SAY-5 wants to merge 3 commits into
hashicorp:mainfrom
SAY-5:fix/pki-enforce-hostnames-underscore-san-31925

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 21, 2026

Description

The PKI API docs state that enforce_hostnames=false "allows non-hostnames in DNS SANs". In practice, GenerateCreationBundle ran every alt-name through idna (StrictDomainName=true) and then through wildHostnameRegex unconditionally, so a SAN containing an underscore was either:

  • v1.20.3 and earlier: silently dropped from the issued certificate with no warning, or
  • main: rejected with subject alternate name <name> is not a valid DNS name and cannot be included as a SAN.

Neither matches the documented behaviour.

Fix

When the role has enforce_hostnames=false, accept the SAN verbatim (or the idna-converted form that doesn't match the hostname regex) instead of failing. enforce_hostnames=true, the default, is unchanged.

Fixes

Fixes #31925

Checklist

  • go build ./builtin/logical/pki/... green.
  • gofmt clean.

Signed-off-by: SAY-5 SAY-5@users.noreply.github.com

The PKI API docs document enforce_hostnames=false as disabling DNS-
name validation on DNS SANs. In practice, GenerateCreationBundle ran
every alt-name through idna (StrictDomainName=true) and then through
wildHostnameRegex unconditionally, so a SAN containing an underscore
was either silently dropped (v1.20.3) or rejected with
"subject alternate name <name> is not a valid DNS name" (main).

When the role has enforce_hostnames=false, accept the SAN verbatim
(or the idna-converted form that doesn't match the hostname regex)
instead of failing. This matches the API contract the docs already
state, and leaves enforce_hostnames=true (the default) exactly as
strict as before.

Fixes hashicorp#31925.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
@SAY-5 SAY-5 requested a review from a team as a code owner April 21, 2026 23:04
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

@SAY-5 is attempting to deploy a commit to the HashiCorp Team on Vercel.

A member of the Team first needs to authorize it.

@hashicorp-cla-app
Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

1 similar comment
@hashicorp-cla-app
Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@dosubot dosubot Bot added the secret/pki label Apr 21, 2026
@heatherezell
Copy link
Copy Markdown
Contributor

Please sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PKI: enforce_hostnames=false does not allow underscores in DNS SANs

2 participants