1 import ./make-test-python.nix ({ pkgs, ...} : {
4 nodes.machine = { config, lib, pkgs, ... }:
6 networking.firewall.allowedTCPPorts = [ config.services.cfssl.port ];
8 services.cfssl.enable = true;
9 systemd.services.cfssl.after = [ "cfssl-init.service" ];
11 systemd.services.cfssl-init = {
12 description = "Initialize the cfssl CA";
13 wantedBy = [ "multi-user.target" ];
17 WorkingDirectory = config.services.cfssl.dataDir;
19 script = with pkgs; ''
20 ${cfssl}/bin/cfssl genkey -initca ${pkgs.writeText "ca.json" (builtins.toJSON {
21 hosts = [ "ca.example.com" ];
23 algo = "rsa"; size = 4096; };
28 O = "Internet Widgets, LLC";
29 OU = "Certificate Authority";
33 })} | ${cfssl}/bin/cfssljson -bare ca
40 cfsslrequest = with pkgs; writeScript "cfsslrequest" ''
41 curl -f -X POST -H "Content-Type: application/json" -d @${csr} \
42 http://localhost:8888/api/v1/cfssl/newkey | ${cfssl}/bin/cfssljson /tmp/certificate
44 csr = pkgs.writeText "csr.json" (builtins.toJSON {
45 CN = "www.example.com";
46 hosts = [ "example.com" "www.example.com" ];
55 O = "Example Company, LLC";
63 machine.wait_for_unit("cfssl.service")
64 machine.wait_until_succeeds("${cfsslrequest}")
65 machine.succeed("ls /tmp/certificate-key.pem")