# 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" ''; }; }; }