Conversation
- `trigger_server_tls_setup_callback` selected servers with `name LIKE '%.<domain>'`. SQL `%` matches dots, so a wildcard certificate for a parent root domain also selected every server whose own root domain is nested inside it -- `%.fc.dev` matches `n2.internal.fc.dev`. - A wildcard covers exactly one label, so `*.fc.dev` is not valid for `n2.internal.fc.dev`. Pushing it there replaces a working certificate with one that fails hostname verification, breaking agent communication until it is repaired by hand. - Match `domain` exactly instead. This mirrors `BaseServer.get_certificate`, which already resolves the reverse mapping with an exact `domain` match -- the two are inverses of each other and disagreed. - Add a regression test covering both halves: the parent domain's servers are still targeted, and the nested domain's servers are not.
Contributor
Confidence Score: 5/5Safe to merge. The filter aligns certificate deployment with persisted server root domains, and no actionable defect was found. Reviews (1): Last reviewed commit: "fix(tls): Don't push a wildcard cert to ..." | Re-trigger Greptile |
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.
Problem
TLSCertificate.trigger_server_tls_setup_callback()picks the servers to push a renewed wildcard certificate to by pattern-matching the server's name:SQL
%matches any character, dots included. So a wildcard certificate for a parent root domain also selects every server whose own root domain is nested inside it —%.fc.devmatchesn2.internal.fc.devjust as readily asn1.fc.dev.A wildcard covers exactly one label, so
*.fc.devis not valid forn2.internal.fc.dev. The push replaces a working certificate with one that fails hostname verification, and every agent request to that server then dies with:This is silent until something tries to talk to the agent. In our deployment it broke site backups for ~28 hours before anyone noticed, and it recurs on every renewal of the parent domain's certificate.
It only affects installs that nest one Root Domain inside another — e.g. tenant sites on
fc.devwith server hostnames underinternal.fc.dev.Fix
Match
domainexactly instead of pattern-matching the name.This isn't a new convention — it's the one the codebase already uses.
BaseServer.get_certificate()resolves the reverse mapping with an exactdomainmatch:The two functions are inverses of one another and disagreed: one exact, one fuzzy. After this change they agree.
setup_standalone_wildcard_hosts()in the same file already filters ondomainexactly too.All nine server doctypes in the list (
Server,Proxy Server,Database Server,Log,Monitor,Registry,Analytics,Trace,NAT Server) carrydomainas a Link toRoot Domain, so the filter is valid for each.Tenant-site TLS is unaffected: that travels via
_update_secondary_wildcard_domains()/setup_standalone_wildcard_hosts()→setup_wildcard_hosts()on the agent API, not through this callback'stls.ymlpath. A proxy serving*.fc.devfor tenant sites still receives it.Test
test_wildcard_renewal_does_not_target_servers_in_a_nested_root_domainasserts both halves, since a fix that stopped the over-matching but also stopped legitimate renewals would trade a loud failure for a silent one:Verification
Reproduced and confirmed against a live install by calling the real
trigger_server_tls_setup_callback()withfrappe.enqueuestubbed out and the transaction rolled back, on a deployment with<tenant>.example.comsites and*.internal.example.comserver hostnames:*.example.cominternal.servers*.internal.example.com🤖 Generated with Claude Code