Repository navigation
fix(blueprints): pick the most specific domain for private resources - #4034
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
A private blueprint resource whose full-domain matched both a parent and a nested wildcard domain was attached to whichever domain the query returned first, so somename.int.example.com could be filed under *.example.com with the subdomain "somename.int". The public resource path already selects the longest matching base domain; use the same selection for private resources.
Tyagiquamar
requested review from
miloschwartz and
oschwartz10612
as code owners
October 30, 2026 13:50
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.
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
AI Disclosure
An AI coding agent assisted with locating the cause and writing the change and the test. I reviewed the result and ran the checks below.
Description
Fixes #3878.
When a Docker blueprinted private resource declared a
full-domainthat matched more than one verified domain, the resource was attached to whichever matching domain the database returned first. With both*.example.comand*.int.example.comverified, a resource forsomename.int.example.comcould be stored under*.example.comwithsubdomainset tosomename.intinstead of under*.int.example.comwithsubdomainset tosomename. The certificate was then tracked against the wrong domain and showed up as failed in the dashboard even though the correct wildcard certificate was being served. Creating the same resource through the UI is unaffected because the domain is selected explicitly there.The public resource blueprint path (
getDomainIdinserver/lib/blueprints/publicResources.ts) already sorts the matching domains by the length ofbaseDomainfor exactly this case. The private resource path did not.Technical solution
server/lib/blueprints/domainSelection.tswithmatchesFullDomain(same rules as before:nsandwildcardmatch their base domain and subdomains,cnamematches only the exact base domain) andselectMostSpecificDomain, which picks the longest matchingbaseDomain.getDomainForSiteResourceinserver/lib/blueprints/privateResources.tsnow selects the domain throughselectMostSpecificDomaininstead of takingvalidDomains[0].With the previous selection the regression test case below resolves to
example.com; with the change it resolves toint.example.com.How to test?
server/lib/blueprints/domainSelection.test.tscovers a parent domain listed before a nested wildcard (the reported case), an exact base-domain match, a CNAME that only matches its base domain, and a full domain with no matching domain.npm test/node scripts/run-tests.mjs.Commands run:
On Windows the dependency install used
npm ci --ignore-scriptsbecausebetter-sqlite3has no win32 prebuild for this Node version; neithertscnor this test depends on the native module.