about summary refs log tree commit diff stats
path: root/hosts/by-name/server2
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-21 12:26:14 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-29 15:13:15 +0100
commit5c28c5d242c60c0fdceffa88a33c65d540e1c8b7 (patch)
treea65b4547f7cc73f08e947d209b929452a3e7b2f5 /hosts/by-name/server2
parenttests/email-dns/secrets: Re-key secrets, so that soispha and sils can read them (diff)
downloadnixos-server-5c28c5d242c60c0fdceffa88a33c65d540e1c8b7.zip
hosts/server2: Setup stalwalt-mail on mail.vhack.eu for soispha@vhack.eu
We need to actually test stalwart out in the real world, because the
test can never actually capture all the weird things people do with
their mail setup.

Refs: #6ea08aa
Diffstat (limited to '')
-rw-r--r--hosts/by-name/server2/configuration.nix31
-rwxr-xr-xhosts/by-name/server2/secrets/dkim/gen_key.sh33
-rw-r--r--hosts/by-name/server2/secrets/dkim/mail.vhack.eu-private.age16
-rw-r--r--hosts/by-name/server2/secrets/dkim/mail.vhack.eu-public1
4 files changed, 81 insertions, 0 deletions
diff --git a/hosts/by-name/server2/configuration.nix b/hosts/by-name/server2/configuration.nix
index 5fe635a..cbc1ff3 100644
--- a/hosts/by-name/server2/configuration.nix
+++ b/hosts/by-name/server2/configuration.nix
@@ -57,6 +57,37 @@
       enable = true;
       fqdn = "mail.foss-syndicate.org";
     };
+    stalwart-mail = {
+      enable = true;
+      fqdn = "mail.vhack.eu";
+      admin = "admin@vhack.eu";
+      security = {
+        dkimKeys = let
+          loadKey = name: {
+            dkimPublicKey = builtins.readFile (./secrets/dkim + "/${name}/public");
+            dkimPrivateKeyPath = ./secrets/dkim + "/${name}/private.age";
+            keyAlgorithm = "ed25519-sha256";
+          };
+        in {
+          "mail.vhack.eu" = loadKey "vhack.eu";
+        };
+        verificationMode = "strict";
+      };
+      openFirewall = true;
+      principals = [
+        {
+          class = "individual";
+          name = "soispha";
+          secret = "$2b$05$XX36sJuHNbTFvi8DFldscOeQBHahluSkiUqD9QGzQaET7NJusSuQW";
+          email = [
+            "soispha@vhack.eu"
+            "abuse@vhack.eu"
+            "postmaster@vhack.eu"
+            "admin@vhack.eu"
+          ];
+        }
+      ];
+    };
     nginx = {
       enable = true;
       redirects = {
diff --git a/hosts/by-name/server2/secrets/dkim/gen_key.sh b/hosts/by-name/server2/secrets/dkim/gen_key.sh
new file mode 100755
index 0000000..61da156
--- /dev/null
+++ b/hosts/by-name/server2/secrets/dkim/gen_key.sh
@@ -0,0 +1,33 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -p rage -p openssl -p bash -i bash --impure
+
+# shellcheck shell=bash
+
+cd "$(dirname "$0")" || {
+    echo "No basedir?!"
+    exit 1
+}
+
+key_name="$1"
+[ -z "$key_name" ] && {
+    echo "Usage: $0 KEY_NAME IDENTITY"
+    exit 2
+}
+
+openssl genpkey \
+    -algorithm ed25519 \
+    -out - |
+    tee >(openssl pkey \
+        -pubout \
+        -out - |
+        openssl asn1parse \
+            -offset 12 \
+            -noout \
+            -out - |
+        base64 --wrap 0 >"$key_name-public") |
+    rage --encrypt \
+        --armor \
+        --recipient "age1mshh4ynzhhzhff25tqwkg4j054g3xwrfznh98ycchludj9wjj48qn2uffn" \
+        >"$key_name-private.age"
+
+# vim: ft=sh
diff --git a/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-private.age b/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-private.age
new file mode 100644
index 0000000..586a266
--- /dev/null
+++ b/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-private.age
@@ -0,0 +1,16 @@
+-----BEGIN AGE ENCRYPTED FILE-----
+YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB5TXdkcGE3VDhPVFd1aThX
+dno3RWtMbE9vR1NuQjJXR003NmxrbllSTVhVCit5aExOb2NVSzFKZWswNlQ3R3ds
+Rkt3QjU4dlUyVEdQaWFFbU9iejJOV28KLT4gWDI1NTE5IFFoVjFhMWlzUUlPWUFK
+cEcwVlQrbzhkRjdEU2FoNmJ2MGpkc1NLcG5zZ1EKNnc0R3BGR0FSQWUvTlIyTk94
+ME82VDRnTytwZnAvVUl6bEFzSTFNUm5BQQotPiBzc2gtZWQyNTUxOSBYUG94RFEg
+eFRmUlY2QUhUdUNWQ0xMai9IMEFJZWQxWG9MUktDMnIycnNIS3NELzFGMApxbkx3
+ZlFJTzVNTjlKSzNkOW9reXFYM04xQThQNGgvblNBRUJyZk1HUUZZCi0+IHozLWdy
+ZWFzZSBuJT0Ka3NhLzVpY0Z0TW5HckJYUEhpZWlRazFjbzZEMTBwanRFdVA2WWNx
+SUpLQitzNUlCQlpQQkZrZDRvbFdBMUgzVApnZ3MyMzF6dlRKZmxmd3NQejJJeE1q
+YTVvUExxTTVIVkNNWldyWkY4b3cKLS0tIHYyRWV4WEo4RW1aK3E0MkNucnp1SVVQ
+ZHdORjY2Z2IvMkI3a0VQbllWdncKej5N7MfXO+6MbxluZfM+Df75nBiNAEhrkvqX
+dHB6qKXScbQHQp9Dpsuv/eR+vaW3rMstOMkAas4RDCii1iDwv2MjXtrFcPKXCBiz
+/aiPvmn/7f/cXFw6pTSmLsF2AXGy2wepOEdIVQM4Gml7yVgVhQ3cK4QRGzPjW4Yf
+urNumFlJQ7a8NVFNK2C9a+bfIz0eUYcJrOOjBg==
+-----END AGE ENCRYPTED FILE-----
diff --git a/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-public b/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-public
new file mode 100644
index 0000000..7654a2c
--- /dev/null
+++ b/hosts/by-name/server2/secrets/dkim/mail.vhack.eu-public
@@ -0,0 +1 @@
+U0eOxgLD3yK7PKzQRSZdJ3EH/UwVxPeYmfm42gYXsDg=
\ No newline at end of file