fix(ssl): warn when the letsencrypt account key is missing but cert state exists#500
Open
mrrobot47 wants to merge 1 commit into
Open
fix(ssl): warn when the letsencrypt account key is missing but cert state exists#500mrrobot47 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
setAcmeClient()is binary: if the Let's Encrypt account key (acme-conf/account/key.private.pem) is present it loads it, otherwise it silently generates a new one. If that key is wiped while LE certs still exist (host migration, snapshot restore, mis-fired cleanup), the next run silently mints a fresh account key — orphaning the existing LE registration, so later renewals/issuance fail with 401s and no diagnostic.Fix
Detect the lost-key anomaly and warn loudly (a lost LE account key cannot be recovered, so this is detect-and-warn, not auto-recovery). When the account key is missing AND prior LE state exists on disk —
acme-conf/var/*(orders/challenges/DN) oracme-conf/certs/*(LE keypairs/certs), both written solely by AcmePhp —setAcmeClient()now emits clear warnings (the key appears lost; a new account will orphan the old one so existing certs won't renew until re-issued; restoreacme-conf/account/from backup to preserve it) before proceeding to generate.The signal deliberately uses LE-specific
acme-confstate, notservices/nginx-proxy/certs/(which also holds custom/self-signed certs), so it never false-positives on a non-LE host. On a genuine first run those dirs don't exist yet (AcmePhp creates them only after the account key), so issuance stays silent. The key-present load path and key generation are unchanged.Testing
Manual: with existing LE sites, remove
acme-conf/account/and run any SSL op → the warnings fire instead of a silent re-mint; a fresh host (noacme-conf) and a custom/self-signed-only host stay silent.