diff options
| author | tv <tv@krebsco.de> | 2026-12-03 19:12:05 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-03 22:07:23 +0000 |
| commit | b1bc362ebabdeb26dd37d20effdf68e20a3c2d24 (patch) | |
| tree | 995133a21647c171b8bdbdaf624423fc80a4f4e9 /configs/knot/dane.nix | |
| parent | 040825c1ca77077925fa971160017ca13bebae64 (diff) | |
knot: DANE records for ne
Diffstat (limited to 'configs/knot/dane.nix')
| -rw-r--r-- | configs/knot/dane.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/configs/knot/dane.nix b/configs/knot/dane.nix new file mode 100644 index 00000000..dad21fd6 --- /dev/null +++ b/configs/knot/dane.nix @@ -0,0 +1,51 @@ +# DANE: TLSA records for ne's certificate, for SMTP and HTTPS. +# systems/ne/acme.nix reloads this when the certificate changes. +{ config, pkgs, ... }: { + services.knot.settings = { + acl = { + dane_acl = { + key = "dane"; + action = "update"; + }; + }; + template.internet-notify-he.acl = [ "dane_acl" ]; + }; + + systemd.services."knsupdate-viljetic.de" = { + serviceConfig = { + Type = "oneshot"; + SyslogIdentifier = "knsupdate-viljetic.de"; + ExecStart = pkgs.writeDash "knsupdate-viljetic.de" /* sh */ '' + set -efu + + mk_certificate_association_data() { + ${pkgs.openssl}/bin/openssl x509 -noout -fingerprint -sha256 < "$1" | + ${pkgs.coreutils}/bin/cut -d= -f2 | + ${pkgs.coreutils}/bin/tr -d : + } + + certfile=/var/lib/acme/viljetic.de/cert.pem + certificate_association_data=$(mk_certificate_association_data "$certfile") + keyfile=${config.krebs.secret.directory}/dane.tsig + + script=$(${pkgs.coreutils}/bin/mktemp -t knsupdate.XXXXXXXX) + trap 'rm "$script"' EXIT + ( + exec >"$script" + echo server viljetic.de. + echo zone viljetic.de. + echo origin viljetic.de. + echo del _25._tcp.ne TLSA + echo del _443._tcp.ne TLSA + echo add _25._tcp.ne 60 IN TLSA 3 0 1 $certificate_association_data + echo add _443._tcp.ne 60 IN TLSA 3 0 1 $certificate_association_data + echo show + echo send + echo answer + echo quit + ) + ${pkgs.knot-dns}/bin/knsupdate -k "$keyfile" "$script" + ''; + }; + }; +} |
