From 6d24076c119323bc9e9403c2e03b940c2e961d02 Mon Sep 17 00:00:00 2001 From: KiekerJan Date: Fri, 28 Apr 2023 23:26:11 +0200 Subject: [PATCH] check the mail.rsa key format --- setup/dkim.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup/dkim.sh b/setup/dkim.sh index 9097e452..b4969ec3 100755 --- a/setup/dkim.sh +++ b/setup/dkim.sh @@ -63,9 +63,13 @@ if [ ! -f "$STORAGE_ROOT/mail/dkim/mail.key" ]; then # Change format from pkcs#8 to pkcs#1, dkimpy seemingly is not able to handle the #8 format # See bug https://bugs.launchpad.net/dkimpy/+bug/1978835 - openssl pkey -in $STORAGE_ROOT/mail/dkim/mail.key -traditional -out $STORAGE_ROOT/mail/dkim/mail.key.1 - mv -f $STORAGE_ROOT/mail/dkim/mail.key $STORAGE_ROOT/mail/dkim/mail.key.8 - cp -f $STORAGE_ROOT/mail/dkim/mail.key.1 $STORAGE_ROOT/mail/dkim/mail.key + line=$(head -n 1 mail.key) + if [ ! "$line" = "-----BEGIN RSA PRIVATE KEY-----" ]; then + # Generate pkcs#1 key from the pkcs#8 key + openssl pkey -in $STORAGE_ROOT/mail/dkim/mail.key -traditional -out $STORAGE_ROOT/mail/dkim/mail.key.1 + mv -f $STORAGE_ROOT/mail/dkim/mail.key $STORAGE_ROOT/mail/dkim/mail.key.8 + cp -f $STORAGE_ROOT/mail/dkim/mail.key.1 $STORAGE_ROOT/mail/dkim/mail.key + fi fi if [ ! -f "$STORAGE_ROOT/mail/dkim/box-ed25519.key" ]; then