aboutsummaryrefslogtreecommitdiff
path: root/pw-update-fingerprint
diff options
context:
space:
mode:
Diffstat (limited to 'pw-update-fingerprint')
-rwxr-xr-xpw-update-fingerprint16
1 files changed, 16 insertions, 0 deletions
diff --git a/pw-update-fingerprint b/pw-update-fingerprint
new file mode 100755
index 0000000..e25a0b4
--- /dev/null
+++ b/pw-update-fingerprint
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# update tls_fingerprint entry in ~/.msmtprc
+
+MAILSERVER="mail.server.com"
+PORT="587"
+
+cd $HOME
+
+# get the server fingerprint
+KEY=$(msmtp --serverinfo --tls --tls-certcheck=off --host="$MAILSERVER" --port="$PORT" | grep -E -o "([0-9A-Za-z]{2}:){31}[0-9A-Za-z]{2}")
+
+# replace tls_fingerprint line in .msmtprc
+sed -i "s/^tls_fingerprint.*/tls_fingerprint $KEY/g" .msmtprc
+
+echo ".msmtprc has been updated with the latest $MAILSERVER fingerprint."