Add self-healing TLS certificate lifecycle#4
Merged
Conversation
magiccodingman
marked this pull request as ready for review
July 21, 2026 16:32
Owner
Author
|
validated the fix and code. |
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.
What changed
finallyblockRoot cause
LiveCertProvider.TryLoadIssuedtreated certificates within 30 days of expiration as unusable. That caused TruthGate to immediately fall back to its self-signed certificate while renewal was still pending. If renewal failed once, an otherwise valid public certificate stopped being served early and an expired PFX could remain permanently stuck on disk.The production evidence matches that failure mode:
truthgate.io.pfxwas issued August 17, 2025, expired November 15, 2025, and was never replaced, while new IPNS certificates were still issued successfully in 2026.Recovery behavior
After this version is deployed, the existing expired
truthgate.io.pfxis loaded and classified as expired, the HTTP listener is allowed to start, and the reconciliation worker immediately requests a replacement. A successful replacement is validated, atomically written, reloaded, and switched into the live SNI cache without another restart.Valid certificates that are merely renewal-due remain live while the replacement attempt runs. Failed renewal attempts use bounded backoff and do not displace the currently valid certificate.
Validation
A dedicated .NET 9 test project and GitHub Actions workflow cover:
GitHub Actions successfully restored and compiled the full web project and passed all 6 TLS lifecycle tests on .NET 9.
Deployment note
No manual deletion of
/opt/truthgate/certs/truthgate.io.pfxshould be required. The first post-deployment reconciliation should repair it automatically, assuming HTTP port 80 and DNS still allow Let’s Encrypt HTTP-01 validation.