Add expression for generating linkerd trust anchors
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
{ pkgs ? import <nixpkgs> {}, ca ? "", name ? "ca", ...}:
|
||||
{ pkgs ? import <nixpkgs> {}, ca ? null, name ? "ca", hosts ? [], ...}:
|
||||
with pkgs;
|
||||
let
|
||||
ca_csr = pkgs.writeText "${name}-csr.json" (builtins.toJSON {
|
||||
inherit hosts;
|
||||
CN = "${name}";
|
||||
key = {
|
||||
algo = "rsa";
|
||||
size = 2048;
|
||||
};
|
||||
names = [
|
||||
{
|
||||
CN = "${name}";
|
||||
O = "NixOS";
|
||||
OU = "${name}.pki.caSpec";
|
||||
L = "generated";
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
ca' =
|
||||
let
|
||||
ca_csr = pkgs.writeText "${name}-csr.json" (builtins.toJSON {
|
||||
key = {
|
||||
algo = "rsa";
|
||||
size = 2048;
|
||||
};
|
||||
names = [
|
||||
{
|
||||
CN = "${name}";
|
||||
O = "NixOS";
|
||||
OU = "${name}.pki.caSpec";
|
||||
L = "generated";
|
||||
}
|
||||
];
|
||||
});
|
||||
in
|
||||
pkgs.runCommand "initca" {
|
||||
buildInputs = [ pkgs.cfssl ];
|
||||
} '' cfssl genkey -initca ${ca_csr} | cfssljson -bare ca; \
|
||||
mkdir -p $out; cp *.pem $out'';
|
||||
initca = if ca != "" then ca else ca';
|
||||
} '' cfssl genkey -initca ${ca_csr} | cfssljson -bare ca;
|
||||
mkdir -p $out; cp *.pem $out '';
|
||||
initca = if ca != null then ca else ca';
|
||||
in
|
||||
# make ca derivation sha depend on initca cfssl output
|
||||
pkgs.stdenv.mkDerivation {
|
||||
|
||||
16
modules/linkerd-certs.nix
Normal file
16
modules/linkerd-certs.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
identity = import ./initca.nix {
|
||||
inherit pkgs;
|
||||
name = "linkerd-identity-ca";
|
||||
hosts = [ "identity.linkerd.cluster.local" ];
|
||||
};
|
||||
|
||||
webhook = import ./initca.nix {
|
||||
inherit pkgs;
|
||||
name = "linkerd-webhook-ca";
|
||||
hosts = [ "webhook.linkerd.cluster.local" ];
|
||||
};
|
||||
in {
|
||||
inherit identity webhook;
|
||||
}
|
||||
Reference in New Issue
Block a user