From 44dae5f88e57c97fb0708d1463c76e54ea8e642f Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 26 Aug 2024 18:37:11 +0200 Subject: [PATCH 1/2] bicep/postgres: use snakeoil certs --- hosts/bicep/services/postgres.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hosts/bicep/services/postgres.nix b/hosts/bicep/services/postgres.nix index df92735..516af7d 100644 --- a/hosts/bicep/services/postgres.nix +++ b/hosts/bicep/services/postgres.nix @@ -1,7 +1,4 @@ { config, pkgs, ... }: -let - sslCert = config.security.acme.certs."postgres.pvv.ntnu.no"; -in { services.postgresql = { enable = true; @@ -79,12 +76,16 @@ in systemd.services.postgresql.serviceConfig = { LoadCredential = [ - "cert:${sslCert.directory}/cert.pem" - "key:${sslCert.directory}/key.pem" + "cert:/etc/certs/postgres.crt" + "key:/etc/certs/postgres.key" ]; }; - users.groups.acme.members = [ "postgres" ]; + environment.snakeoil-certs."/etc/certs/postgres" = { + owner = "postgres"; + group = "postgres"; + subject = "/C=NO/O=Programvareverkstedet/CN=postgres.pvv.ntnu.no/emailAddress=drift@pvv.ntnu.no"; + }; networking.firewall.allowedTCPPorts = [ 5432 ]; networking.firewall.allowedUDPPorts = [ 5432 ]; -- 2.44.1 From 210938296ab5a9d7b691797948a79aa9041696b2 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 26 Aug 2024 18:37:14 +0200 Subject: [PATCH 2/2] modules/snakeoil-certs: fix lmao --- modules/snakeoil-certs.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/snakeoil-certs.nix b/modules/snakeoil-certs.nix index b98d127..61f086a 100644 --- a/modules/snakeoil-certs.nix +++ b/modules/snakeoil-certs.nix @@ -50,7 +50,7 @@ in serviceConfig.Type = "oneshot"; script = let openssl = lib.getExe pkgs.openssl; - in lib.concatMapStringsSep "\n----------------\n" ({ name, value }: '' + in lib.concatMapStringsSep "\n" ({ name, value }: '' mkdir -p $(dirname "${value.certificate}") $(dirname "${value.certificateKey}") if ! ${openssl} x509 -checkend 86400 -noout -in ${value.certificate} then @@ -69,6 +69,8 @@ in chown "${value.owner}:${value.group}" "${value.certificateKey}" chmod "${value.mode}" "${value.certificate}" chmod "${value.mode}" "${value.certificateKey}" + + echo "\n-----------------\n" '') (lib.attrsToList cfg); }; systemd.timers."generate-snakeoil-certs" = { -- 2.44.1