git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #72007 from NinjaTrappeur/nin-acme-custom-dir-uri

nixos/acme: Custom ACME endpoint

commit992035cff0fe9400b66440ee8ab401c8488aed53 authorFlorian Klink <flokli@flokli.de> dateWed 30 Oct 2019, 12:17 (7 years ago) parentaad81ec781f0cf
4 files changed+38−54
nixos/modules/security/acme.nix+30−16 nixos/tests/acme.nix+7−2 nixos/tests/common/letsencrypt/0001-Change-ACME-directory-endpoint-to-directory.patch−25 nixos/tests/common/letsencrypt/default.nix+1−11
nixos/modules/security/acme.nix+30−16
@@ -20,6 +20,16 @@ let
2020 '';
2121 };
2222
23+ server = mkOption {
24+ type = types.nullOr types.str;
25+ default = null;
26+ description = ''
27+ ACME Directory Resource URI. Defaults to let's encrypt
28+ production endpoint,
29+ https://acme-v02.api.letsencrypt.org/directory, if unset.
30+ '';
31+ };
32+
2333 domain = mkOption {
2434 type = types.str;
2535 default = name;
@@ -109,7 +119,15 @@ in
109119{
110120
111121 ###### interface
112−
122+ imports = [
123+ (mkRemovedOptionModule [ "security" "acme" "production" ] ''
124+ Use security.acme.server to define your staging ACME server URL instead.
125+
126+ To use the let's encrypt staging server, use security.acme.server =
127+ "https://acme-staging-v02.api.letsencrypt.org/directory".
128+ ''
129+ )
130+ ];
113131 options = {
114132 security.acme = {
115133
@@ -129,6 +147,16 @@ in
129147 '';
130148 };
131149
150+ server = mkOption {
151+ type = types.nullOr types.str;
152+ default = null;
153+ description = ''
154+ ACME Directory Resource URI. Defaults to let's encrypt
155+ production endpoint,
156+ <literal>https://acme-v02.api.letsencrypt.org/directory</literal>, if unset.
157+ '';
158+ };
159+
132160 preliminarySelfsigned = mkOption {
133161 type = types.bool;
134162 default = true;
@@ -142,20 +170,6 @@ in
142170 '';
143171 };
144172
145− production = mkOption {
146− type = types.bool;
147− default = true;
148− description = ''
149− If set to true, use Let's Encrypt's production environment
150− instead of the staging environment. The main benefit of the
151− staging environment is to get much higher rate limits.
152−
153− See
154− <literal>https://letsencrypt.org/docs/staging-environment</literal>
155− for more detail.
156− '';
157− };
158−
159173 certs = mkOption {
160174 default = { };
161175 type = with types; attrsOf (submodule certOpts);
@@ -198,7 +212,7 @@ in
198212 ++ optionals (data.email != null) [ "--email" data.email ]
199213 ++ concatMap (p: [ "-f" p ]) data.plugins
200214 ++ concatLists (mapAttrsToList (name: root: [ "-d" (if root == null then name else "${name}:${root}")]) data.extraDomains)
201− ++ optionals (!cfg.production) ["--server" "https://acme-staging-v02.api.letsencrypt.org/directory"];
215+ ++ optionals (cfg.server != null || data.server != null) ["--server" (if data.server == null then cfg.server else data.server)];
202216 acmeService = {
203217 description = "Renew ACME Certificate for ${cert}";
204218 after = [ "network.target" "network-online.target" ];
nixos/tests/acme.nix+7−2
@@ -12,8 +12,11 @@ in import ./make-test.nix {
1212 networking.extraHosts = ''
1313 ${config.networking.primaryIPAddress} standalone.com
1414 '';
15− security.acme.certs."standalone.com" = {
16− webroot = "/var/lib/acme/acme-challenges";
15+ security.acme = {
16+ server = "https://acme-v02.api.letsencrypt.org/dir";
17+ certs."standalone.com" = {
18+ webroot = "/var/lib/acme/acme-challenges";
19+ };
1720 };
1821 systemd.targets."acme-finished-standalone.com" = {};
1922 systemd.services."acme-standalone.com" = {
@@ -54,6 +57,8 @@ in import ./make-test.nix {
5457 '';
5558 };
5659
60+ security.acme.server = "https://acme-v02.api.letsencrypt.org/dir";
61+
5762 nesting.clone = [
5863 ({pkgs, ...}: {
5964
nixos/tests/common/letsencrypt/0001-Change-ACME-directory-endpoint-to-directory.patchdeleted−25
@@ -1,25 +0,0 @@
1−From c3b4004386074342d22cab5e129c1f7e623f4272 Mon Sep 17 00:00:00 2001
2−From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= <felix@alternativebit.fr>
3−Date: Mon, 21 Oct 2019 10:56:13 +0200
4−Subject: [PATCH] Change ACME directory endpoint to /directory
5−
6−---
7− wfe/wfe.go | 2 +-
8− 1 file changed, 1 insertion(+), 1 deletion(-)
9−
10−diff --git a/wfe/wfe.go b/wfe/wfe.go
11−index e24797f..10d29fb 100644
12−--- a/wfe/wfe.go
13−+++ b/wfe/wfe.go
14−@@ -39,7 +39,7 @@ const (
15− // Note: We deliberately pick endpoint paths that differ from Boulder to
16− // exercise clients processing of the /directory response
17− // We export the DirectoryPath so that the pebble binary can reference it
18−- DirectoryPath = "/dir"
19−+ DirectoryPath = "/directory"
20− noncePath = "/nonce-plz"
21− newAccountPath = "/sign-me-up"
22− acctPath = "/my-account/"
23−--
24−2.23.0
25−
nixos/tests/common/letsencrypt/default.nix+1−11
@@ -62,17 +62,7 @@ let
6262 siteDomain = "letsencrypt.org";
6363 siteCertFile = snakeOilCerts.${siteDomain}.cert;
6464 siteKeyFile = snakeOilCerts.${siteDomain}.key;
65− pebble = pkgs.pebble.overrideAttrs (attrs: {
66− # The pebble directory endpoint is /dir when the bouder (official
67− # ACME server) is /directory. Sadly, this endpoint is hardcoded,
68− # we have to patch it.
69− #
70− # Tried to upstream, that said upstream maintainers rather keep
71− # this custom endpoint to test ACME clients robustness. See
72− # https://github.com/letsencrypt/pebble/issues/283#issuecomment-545123242
73− patches = [ ./0001-Change-ACME-directory-endpoint-to-directory.patch ];
74− });
75−
65+ pebble = pkgs.pebble;
7666 resolver = let
7767 message = "You need to define a resolver for the letsencrypt test module.";
7868 firstNS = lib.head config.networking.nameservers;