Fix: SSL toggles reset to off when requesting a new certificate on host creation#5701
Open
adman234 wants to merge 1 commit into
Open
Conversation
…ng a new certificate on host creation
When creating a Proxy Host, Redirection Host, or 404 Host and requesting
a brand new Let's Encrypt certificate in the same submission, the
ssl_forced/http2_support/hsts_enabled/hsts_subdomains fields the user
enabled on the form were silently discarded and saved as false.
Root cause: certificate_id is deleted from the payload before the
initial insert (since "new" is not a real certificate id yet), so
cleanSslHstsData() sees no certificate_id and zeroes the SSL toggles
under its "no cert means SSL can't be forced" invariant - even though
a certificate is about to be created moments later in the same
request. The follow-up update() call that attaches the freshly
created certificate_id only passed { id, certificate_id }, so the
user's original toggle values were never re-applied.
Fix: skip the premature cleanSslHstsData() zeroing during the initial
insert when a certificate is being created, and forward the originally
submitted ssl_forced/http2_support/hsts_enabled/hsts_subdomains values
in the follow-up update() call, once the real certificate exists to
validate them against.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Docker Image for build 1 is available on DockerHub: Note Ensure you backup your NPM instance before testing this image! Especially if there are database changes. Warning Changes and additions to DNS Providers require verification by at least 2 members of the community! |
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.
Human edit: I apologize for the AI vibe PR, but this is a bug that has bothered me for a while, so hopefully this PR makes sense and is helpful and easy to review. I am not a developer, so I apologize if any of this is not formatted correctly.
Why
When creating a Proxy Host (also affects Redirection Hosts and 404 Hosts) and requesting a brand new Let's Encrypt certificate in the same submission, any SSL-related toggles enabled on the form — Force SSL, HTTP/2 Support, HSTS Enabled, HSTS Subdomains — are silently discarded and saved as
false. The certificate itself is created successfully, but the toggles have to be re-enabled manually afterwards.Root cause
The whole "create host + request cert" flow happens inside a single
create()call (e.g.backend/internal/proxy-host.js):certificate_idis"new"at this point (not a real ID yet), so it's deleted from the payload before the initial row insert.internalHost.cleanSslHstsData()runs. Its job is to enforce "if there's no certificate,ssl_forced/http2_support/hsts_*must befalse" — a legitimate invariant, but it fires here even though a certificate is about to be created a few lines later in the same request. The user'struetoggle values get zeroed out, and that zeroed-out row is what actually gets inserted.update()again to attach the newcertificate_idto the host — but that follow-up call only passes{ id, certificate_id }. The user's original SSL toggle choices are never re-sent, so they remainfalsepermanently.Editing an existing host while simultaneously requesting a new certificate does not hit this bug — that code path happens to keep the original submitted data object intact through the certificate-creation step, so the toggles survive. It's specifically the "create a new host + request a new cert" combination that's broken.
The identical defect pattern exists in
backend/internal/dead-host.js(404 Hosts) andbackend/internal/redirection-host.js(Redirection Hosts), so this PR fixes all three.What changed
cleanSslHstsData()call during the initial insert when a certificate is about to be created (the invariant doesn't apply yet — the certificate is guaranteed to exist by the time the request finishes).ssl_forced/http2_support/hsts_enabled/hsts_subdomainsvalues in the follow-upupdate()call that attaches the freshly createdcertificate_id, socleanSslHstsData()re-validates them once a real certificate exists.No API contract changes — the fields accepted/returned are unchanged, only the values actually persisted are corrected.
Testing
cleanSslHstsData()reproducing both the old broken output (all SSL fieldsfalseafter create) and the new correct output (all fields preserved as submitted, once the certificate is attached).biome lintpasses clean on all three changed files.Type of Change
AI Usage