summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-03 19:12:05 +0000
committertv <tv@krebsco.de>2026-12-03 22:07:23 +0000
commitb1bc362ebabdeb26dd37d20effdf68e20a3c2d24 (patch)
tree995133a21647c171b8bdbdaf624423fc80a4f4e9
parent040825c1ca77077925fa971160017ca13bebae64 (diff)
knot: DANE records for ne
-rw-r--r--configs/knot/dane.nix51
-rw-r--r--configs/knot/default.nix1
2 files changed, 52 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"
+ '';
+ };
+ };
+}
diff --git a/configs/knot/default.nix b/configs/knot/default.nix
index 001049a7..c64715a9 100644
--- a/configs/knot/default.nix
+++ b/configs/knot/default.nix
@@ -2,6 +2,7 @@
imports = [
./viljetic.de.nix
./tv.krebsco.de.nix
+ ./dane.nix
];
hrm.nftables.input.internet.udp = [ "domain" ];