1 import ./make-test-python.nix ({ pkgs, ... }:
3 test-certificates = pkgs.runCommandLocal "test-certificates" { } ''
5 echo insecure-root-password > $out/root-password-file
6 echo insecure-intermediate-password > $out/intermediate-password-file
7 ${pkgs.step-cli}/bin/step certificate create "Example Root CA" $out/root_ca.crt $out/root_ca.key --password-file=$out/root-password-file --profile root-ca
8 ${pkgs.step-cli}/bin/step certificate create "Example Intermediate CA 1" $out/intermediate_ca.crt $out/intermediate_ca.key --password-file=$out/intermediate-password-file --ca-password-file=$out/root-password-file --profile intermediate-ca --ca $out/root_ca.crt --ca-key $out/root_ca.key
16 { config, pkgs, ... }: {
22 intermediatePasswordFile = "${test-certificates}/intermediate-password-file";
24 dnsNames = [ "caserver" ];
25 root = "${test-certificates}/root_ca.crt";
26 crt = "${test-certificates}/intermediate_ca.crt";
27 key = "${test-certificates}/intermediate_ca.key";
30 dataSource = "/var/lib/step-ca/db";
45 { config, pkgs, ... }: {
46 security.acme.defaults.server = "https://caserver:8443/acme/acme/directory";
47 security.acme.defaults.email = "root@example.org";
48 security.acme.acceptTerms = true;
50 security.pki.certificateFiles = [ "${test-certificates}/root_ca.crt" ];
52 networking.firewall.allowedTCPPorts = [ 80 443 ];
66 { config, pkgs, ... }: {
67 security.pki.certificateFiles = [ "${test-certificates}/root_ca.crt" ];
69 networking.firewall.allowedTCPPorts = [ 80 443 ];
73 virtualHosts."caclientcaddy".extraConfig = ''
74 respond "Welcome to Caddy!"
76 tls caddy@example.org {
77 ca https://caserver:8443/acme/acme/directory
83 catester = { config, pkgs, ... }: {
84 security.pki.certificateFiles = [ "${test-certificates}/root_ca.crt" ];
91 caserver.wait_for_unit("step-ca.service")
92 caserver.wait_until_succeeds("journalctl -o cat -u step-ca.service | grep '${pkgs.step-ca.version}'")
94 caclient.wait_for_unit("acme-finished-caclient.target")
95 catester.succeed("curl https://caclient/ | grep \"Welcome to nginx!\"")
97 caclientcaddy.wait_for_unit("caddy.service")
98 catester.succeed("curl https://caclientcaddy/ | grep \"Welcome to Caddy!\"")