mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6195] [MERGED] fix(nodes): persist the master mTLS credential atomically and stop silent reissue #6156
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6156
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6195
Author: @n0ctal
Created: 8/10/2026
Status: ✅ Merged
Merged: 8/14/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-mtls-credential-persistence📝 Commits (3)
427c0c4fix: harden master mTLS credential persistence2000e00fix(mtls): validate and serialize credential persistence82260a2Merge branch 'main' into upstream-mtls-credential-persistence📊 Changes
4 files changed (+225 additions, -2 deletions)
View changed files
📝
internal/web/service/setting.go(+1 -0)📝
internal/web/service/setting_factory_defaults_test.go(+1 -0)📝
internal/web/service/setting_mtls.go(+74 -2)📝
internal/web/service/setting_mtls_test.go(+149 -0)📄 Description
Summary
Make the master mTLS credential persist atomically and refuse to silently reissue when the stored state is incomplete or inconsistent.
Why
EnsureMasterClientCertstores the certificate, the key and the pin as separate writes. A failure between them leaves a state nobody planned for: a pin without a credential, or a credential that does not match the pin. On the next start the panel cannot tell "never issued" from "issued and partly lost", and mints a replacement — silently stranding every node that already enforces the old leaf identity.Scope
Validation
go test ./...green;go test -race ./internal/web/service -run TestEnsureMasterClientCertgreen.Not proven: the same rollback was not separately provoked on PostgreSQL. It is verified on SQLite and follows from the shared GORM transaction path.
Risk
Low. An installation with a complete, consistent credential sees no change. The new refusals replace cases that previously produced a silent reissue.
Update after review
The premise in the Why section above overstated the consequence, and the code now matches reality rather than that premise:
ClientCAs(internal/web/web_mtls.go) and API auth accepts any verified chain. A replacement leaf is therefore trusted by existing nodes as long as the CA pair survives — a lost leaf is a recoverable condition, not the fleet-wide outage the original wording implied.tls.X509KeyPair.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.