Skip to content

Commit

Permalink
nixos/acme: Disable lego renew sleeping
Browse files Browse the repository at this point in the history
Lego has a built-in mechanism for sleeping for a random amount
of time before renewing a certificate. In our environment this
is not only unnecessary (as our systemd timer takes care of it)
but also unwanted since it slows down the execution of the
systemd service encompassing it, thus also slowing down the
start up of any services its depending on.

Also added FixedRandomDelay to the timer for more predictability.
  • Loading branch information
m1cr0man authored and winterqt committed Oct 6, 2022
1 parent 657ecbc commit 49c0fd7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nixos/modules/security/acme/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let
);
renewOpts = escapeShellArgs (
commonOpts
++ [ "renew" ]
++ [ "renew" "--no-random-sleep" ]
++ optionals data.ocspMustStaple [ "--must-staple" ]
++ data.extraLegoRenewFlags
);
Expand Down Expand Up @@ -223,9 +223,9 @@ let
# have many certificates, the renewals are distributed over
# the course of the day to avoid rate limits.
AccuracySec = "${toString (_24hSecs / numCerts)}s";

# Skew randomly within the day, per https://letsencrypt.org/docs/integration-guide/.
RandomizedDelaySec = "24h";
FixedRandomDelay = true;
};
};

Expand Down
5 changes: 0 additions & 5 deletions nixos/tests/common/acme/client/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ in {
defaults = {
server = "https://${caDomain}/dir";
email = "hostmaster@example.test";
# Avoid a random 0-8 minute sleep when testing renewals.
# We are not using LE servers in testing so this is not
# going to impact their load.
# See https://github.com/go-acme/lego/issues/1656
extraLegoRenewFlags = ["-no-random-sleep"];
};
};

Expand Down

0 comments on commit 49c0fd7

Please sign in to comment.