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