fix(ssl): deploy nginx-proxy certs atomically with checked copies#491
Open
mrrobot47 wants to merge 1 commit into
Open
fix(ssl): deploy nginx-proxy certs atomically with checked copies#491mrrobot47 wants to merge 1 commit into
mrrobot47 wants to merge 1 commit into
Conversation
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
moveCertsToNginxProxy()deployed the freshly-issued cert with three sequential barecopy()calls (key, crt, chain) intoservices/nginx-proxy/certs/, ignoring every return value and with no temp-file + rename. A failure between copies (disk full, permissions, crash) left nginx-proxy pointing at a mismatched key/cert pair. This runs on both first issuance and renewal (the unattended cron path).Fix
Copy each source to a temp file in the destination directory (checking
copy()), thenrename()each into place (checkingrename()).rename()is atomic on the same filesystem, so a failed copy can no longer leave a half-written live key/cert. On any failure the temp files are cleaned up and an exception is thrown, rather than silently leaving a partial deploy.Notes
voidand throws on failure:executeRenewal()already wraps the call in try/catch (surfaces as a renewal warning); on first issuance the exception propagates as a loud failure — preferable to the previous silent broken-cert outcome.Testing
Manual (needs the EE + Docker harness): issue/renew a cert and confirm
.key/.crt/.chain.pemdeploy together with no.tmpleftovers; make the certs dir unwritable to force a failure and confirm it errors without leaving a mismatched pair.