1 # The certificate for the ACME service is exported as:
3 # config.test-support.acme.caCert
5 # This value can be used inside the configuration of other test nodes to inject
6 # the test certificate into security.pki.certificateFiles or into package
9 # Another value that's needed if you don't use a custom resolver (see below for
10 # notes on that) is to add the acme node as a nameserver to every node
11 # that needs to acquire certificates using ACME, because otherwise the API host
12 # for acme.test can't be resolved.
14 # A configuration example of a full node setup using this would be this:
17 # acme = import ./common/acme/server;
19 # example = { nodes, ... }: {
20 # networking.nameservers = [
21 # nodes.acme.networking.primaryIPAddress
23 # security.pki.certificateFiles = [
24 # nodes.acme.test-support.acme.caCert
29 # By default, this module runs a local resolver, generated using resolver.nix
30 # from the parent directory to automatically discover all zones in the network.
32 # If you do not want this and want to use your own resolver, you can just
33 # override networking.nameservers like this:
36 # acme = { nodes, lib, ... }: {
37 # imports = [ ./common/acme/server ];
38 # networking.nameservers = lib.mkForce [
39 # nodes.myresolver.networking.primaryIPAddress
46 # Keep in mind, that currently only _one_ resolver is supported, if you have
47 # more than one resolver in networking.nameservers only the first one will be
50 # Also make sure that whenever you use a resolver from a different test node
51 # that it has to be started _before_ the ACME service.
59 testCerts = import ./snakeoil-certs.nix;
60 domain = testCerts.domain;
63 listenAddress = "0.0.0.0:443";
64 managementListenAddress = "0.0.0.0:15000";
65 # These certs and keys are used for the Web Front End (WFE)
66 certificate = testCerts.${domain}.cert;
67 privateKey = testCerts.${domain}.key;
70 ocspResponderURL = "http://${domain}:4002";
74 pebbleConfFile = pkgs.writeText "pebble.conf" (builtins.toJSON pebbleConf);
78 imports = [ ../../resolver.nix ];
80 options.test-support.acme = {
81 caDomain = lib.mkOption {
86 A domain name to use with the `nodes` attribute to
87 identify the CA server.
90 caCert = lib.mkOption {
91 type = lib.types.path;
93 default = testCerts.ca.cert;
95 A certificate file to use with the `nodes` attribute to
96 inject the test CA certificate used in the ACME server into
97 {option}`security.pki.certificateFiles`.
106 isLocalResolver = config.networking.nameservers == [ "127.0.0.1" ];
108 lib.mkOverride 900 isLocalResolver;
111 # This has priority 140, because modules/testing/test-instrumentation.nix
112 # already overrides this with priority 150.
113 networking.nameservers = lib.mkOverride 140 [ "127.0.0.1" ];
114 networking.firewall.allowedTCPPorts = [
121 networking.extraHosts = ''
123 ${config.networking.primaryIPAddress} ${domain}
129 description = "Pebble ACME server";
130 wantedBy = [ "network.target" ];
132 # We're not testing lego, we're just testing our configuration.
134 PEBBLE_VA_NOSLEEP = "1";
138 RuntimeDirectory = "pebble";
139 WorkingDirectory = "/run/pebble";
141 # Required to bind on privileged ports.
142 AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
144 ExecStart = "${pkgs.pebble}/bin/pebble -config ${pebbleConfFile}";