Repository navigation
httpcaddyfile: keep a site block's TLS policy for ECH public names - #8156
Merged
Merged
Conversation
The global ech option added its own automation policy for every public name, even when a site block already had a policy for that name. If the site block set its own TLS options, adapting failed with "hostname appears in more than one automation policy". If a hostless catch-all with the same settings was also present, the site's policy was merged away and the name got only the global settings. Skip public names that already have a policy, as tls_automate_names does, and only add the ECH policy when it still has subjects, since a policy without subjects acts as a catch-all.
steadytao
requested changes
Oct 8, 2026
The check for an existing site policy only matched a subject spelled exactly like the ECH public name. A site policy for *.example.com, or for example.com when the public name is written Example.COM, already covers that name at runtime, but the global ECH policy was still added and sorted ahead of it, so the site's issuer settings were overridden. Lowercase and trim the public name as ECH provisioning does and compare it with certmagic.MatchWildcard, which is how the TLS app picks a policy for a name.
steadytao
approved these changes
Oct 9, 2026
This was referenced Nov 3, 2026
NickCao
pushed a commit
to NickCao/caddy
that referenced
this pull request
Nov 4, 2026
…addyserver#8156) * httpcaddyfile: keep a site block's TLS policy for ECH public names The global ech option added its own automation policy for every public name, even when a site block already had a policy for that name. If the site block set its own TLS options, adapting failed with "hostname appears in more than one automation policy". If a hostless catch-all with the same settings was also present, the site's policy was merged away and the name got only the global settings. Skip public names that already have a policy, as tls_automate_names does, and only add the ECH policy when it still has subjects, since a policy without subjects acts as a catch-all. * httpcaddyfile: check ECH public names the way the TLS app matches them The check for an existing site policy only matched a subject spelled exactly like the ECH public name. A site policy for *.example.com, or for example.com when the public name is written Example.COM, already covers that name at runtime, but the global ECH policy was still added and sorted ahead of it, so the site's issuer settings were overridden. Lowercase and trim the public name as ECH provisioning does and compare it with certmagic.MatchWildcard, which is how the TLS app picks a policy for a name. (cherry picked from commit c8591a1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7354.
The
echglobal option adds an automation policy for each public name without checking whether a site block already has one for it. If the site block sets its own TLS options, liketls internalortls { resolvers ... }, adapting fails with "hostname appears in more than one automation policy". If a hostless catch-all with the same settings is also present, the site's policy is merged away and the name silently gets only the global settings, so atls internalname was requested from Let's Encrypt.This skips public names that a site block's policy already covers, matched the way the TLS app picks a policy at runtime, so a wildcard or differently cased subject counts too. It only adds the ECH policy when it still has subjects.
The five new adapt tests fail on master.
Assistance Disclosure
I directed claude code (opus 5.5), which traced the cause, wrote the fix and tests and ran the checks, and I reviewed the code, tests and evidence before posting.