git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #101482 from m1cr0man/jwsfix

nixos/acme: lego run when account is missing

commit49853c69f582d3c9a8dd013495c9461709d1b7af authorFlorian Klink <flokli@flokli.de> dateSun 20 Dec 2020, 11:06 (6 years ago) parentbc43653e312039
2 files changed+27−2
nixos/modules/security/acme.nix+3−2 nixos/modules/security/acme.xml+24
nixos/modules/security/acme.nix+3−2
@@ -104,7 +104,7 @@ let
104104 mkHash = with builtins; val: substring 0 20 (hashString "sha256" val);
105105 certDir = mkHash hashData;
106106 domainHash = mkHash "${concatStringsSep " " extraDomains} ${data.domain}";
107− othersHash = mkHash "${toString acmeServer} ${data.keyType}";
107+ othersHash = mkHash "${toString acmeServer} ${data.keyType} ${data.email}";
108108 accountDir = "/var/lib/acme/.lego/accounts/" + othersHash;
109109
110110 protocolOpts = if useDns then (
@@ -253,7 +253,8 @@ let
253253 echo '${domainHash}' > domainhash.txt
254254
255255 # Check if we can renew
256− if [ -e 'certificates/${keyName}.key' -a -e 'certificates/${keyName}.crt' ]; then
256+ # Certificates and account credentials must exist
257+ if [ -e 'certificates/${keyName}.key' -a -e 'certificates/${keyName}.crt' -a "$(ls -1 accounts)" ]; then
257258
258259 # When domains are updated, there's no need to do a full
259260 # Lego run, but it's likely renew won't work if days is too low.
nixos/modules/security/acme.xml+24
@@ -263,4 +263,28 @@ chmod 400 /var/lib/secrets/certs.secret
263263 ones.
264264 </para>
265265 </section>
266+ <section xml:id="module-security-acme-fix-jws">
267+ <title>Fixing JWS Verification error</title>
268+
269+ <para>
270+ It is possible that your account credentials file may become corrupt and need
271+ to be regnerated. In this scenario lego will produce the error <literal>JWS verification error</literal>.
272+ The solution is to simply delete the associated accounts file and
273+ re-run the affected service(s).
274+ </para>
275+
276+<programlisting>
277+# Find the accounts folder for the certificate
278+systemctl cat acme-example.com.service | grep -Po 'accounts/[^:]*'
279+export accountdir="$(!!)"
280+# Move this folder to some place else
281+mv /var/lib/acme/.lego/$accountdir{,.bak}
282+# Recreate the folder using systemd-tmpfiles
283+systemd-tmpfiles --create
284+# Get a new account and reissue certificates
285+# Note: Do this for all certs that share the same account email address
286+systemctl start acme-example.com.service
287+</programlisting>
288+
289+ </section>
266290</chapter>