Sign encrypted mails.

- Husk now not only encrypts outgoing emails (if possible) but also adds
  a signature.
- Rework the internal handling of the signing key.
- Integrate the signing into the workflow of the daemon.
- Add a configuration option for a subject replacement.
This commit is contained in:
Malte Meiboom
2026-06-18 13:24:24 +02:00
parent 06c0583f5e
commit e47b1b837c
10 changed files with 155 additions and 47 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ send_test_mail() { # email_address
chown $USER:mail /var/mail/$USER
chmod 600 /var/mail/$USER
echo "test mail" | sendmail $1
echo -e "Subject: testmail\n\ntest mail" | sendmail $1
inotifywait -qq -t 3 -e close_write /var/mail/$USER
}
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/bash
# source some functions
. common.sh
test_header "Signing"
# sq key generate --shared-key --without-password --email 'signing@example.com' --output /tmp/signing.pgp --rev-cert /tmp/signing.rev
SIGN_FPR=$(sq key generate --own-key --without-password --name "Signing Key" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2)
cd $HUSK_DIR
$HUSK_BIN --config config/config.toml signkey set --cert $SIGN_FPR
SIGN_FPR=$($HUSK_BIN --config config/config.toml signkey show | cut -d ':' -f 2 | tr -d ' ')
echo "found signing key $SIGN_FPR"
create_unix_user juliette
JULIETTE_FPR=$(sq key generate --own-key --without-password --name "Juliette" --email "juliette@example.com" 2>&1 | grep "Fingerprint:" | cut -d ':' -f 2)
sq pki vouch add --certifier-userid "CA" --cert $JULIETTE_FPR --all > /dev/null 2>&1
# send a mail, husk should encrypt it
echo "send mail to juliette@example.com"
send_test_mail juliette@example.com
if [ -f /var/mail/juliette ] ; then
if grep -q "BEGIN PGP MESSAGE" /var/mail/juliette ; then
FOUND_FPR=$(sq packet dump /var/mail/juliette | grep "Issuer Fingerprint:" | cut -d ':' -f 2 | tr -d ' ')
if [ "$SIGN_FPR" != "$FOUND_FPR" ] ; then
echo "Found wrong fingerprint '$FOUND_FPR' - expected '$SIGN_FPR'"
RESULT_CODE=1
else
RESULT_CODE=0
fi
else
echo "no encryption detected"
exit 1
fi
else
echo "no mail detected"
exit 1
fi