Init: Working prototype
authorKristian Fiskerstrand <kf@sumptuouscapital.com>
Wed, 31 Dec 2014 02:10:01 +0000 (03:10 +0100)
committerKristian Fiskerstrand <kf@sumptuouscapital.com>
Wed, 31 Dec 2014 02:10:01 +0000 (03:10 +0100)
We have a working prototype of sending voicemail from asterisk as
OpenPGP encrypted emails, however a few things are still remaining
including
        (i)  Dynamic selection of recipient and key to use for multi
             user environments
        (ii) OpenPGP Signature of outgoing message

To use this application specify the following in voicemail.conf
        mailcmd=/usr/local/bin/asterisk-mailsend

asterisk-mailsend [new file with mode: 0644]

diff --git a/asterisk-mailsend b/asterisk-mailsend
new file mode 100644 (file)
index 0000000..125ee45
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+LOCALTEMP=$(/bin/mktemp)
+cat > ${LOCALTEMP}
+
+#TODO: Here we need to actually grab the To: field to see whom it should be sent to
+
+#TODO And here we need to check the return status to ensure it was properly encrypted
+
+TO="kf@sumptuouscapital.com"
+SUBJECT="$(date '+%Y-%m-%d %H:%M:%S'): You have a new VoiceMail message"
+BOUNDARY="-----=${RANDOM}"
+TMP=$(mktemp)
+
+echo "To: ${TO}" >> ${TMP}
+echo "Subject: ${SUBJECT}" >> ${TMP}
+echo "MIME-Version: 1.0" >> ${TMP}
+echo "Content-Type: multipart/encrypted; protocol=\"application/pgp-encrypted\"; boundary=\"${BOUNDARY}\"" >> ${TMP}
+
+echo "" >> ${TMP}
+echo "This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)" >> ${TMP}
+echo "" >> ${TMP}
+echo "--${BOUNDARY}" >> ${TMP}
+echo "Content-Type: application/pgp-encrypted" >> ${TMP}
+echo "Content-Description: PGP/MIME version identification" >> ${TMP}
+echo "" >> ${TMP}
+echo "Version: 1" >> ${TMP}
+echo "" >> ${TMP}
+echo "--${BOUNDARY}" >> ${TMP}
+echo 'Content-Type: application/octet-stream; name="encrypted.asc"' >> ${TMP}
+echo 'Content-Description: OpenPGP encrypted message' >> ${TMP}
+echo 'Content-Disposition: inline; filename="encrypted.asc"' >> ${TMP}
+echo "" >> ${TMP}
+
+/usr/bin/gpg2 --batch --homedir /var/lib/asterisk/.gnupg -aer ${TO} --encrypt ${LOCALTEMP}
+cat ${LOCALTEMP}.asc >> ${TMP}
+
+echo "--${BOUNDARY}--" >> ${TMP}
+
+cat ${TMP} | /usr/bin/sendmail -t
+