> I thought I would write a filter for Pine users to be able to deal > with PGP-MIME signed messages. It struck me that the concept should > be fairly simple. I hacked together a quick shell script that does > the following:
I have two filters which I use with procmail to verify emails coming in. They are run as filters from procmail as :0 HBDf * ^-----BEGIN PGP SIGNED MESSAGE----- | /domain/bin/verify-signature-filter :0 HBDf * ^Content-Type: application/pgp-signature | /domain/bin/mime-verify-signature-filter Maybe they help a little to implement your own filter. btw: If you think there is something to improve this filters (I bet there is plenty) please tell me. Maybe there is a even better filter around. This two skripts where just two hacks to entertain me... :-) -- cu --== Jerri ==-- Homepage: http://www.jerri.de/ ICQ: 54160208
#!/bin/sh # To get a good name which isn't overwritten tempname=check_sign-$RANDOM-$$-$(date +"%Y%m%d%H%M%S") # Create a temporary dir mkdir /tmp/$tempname cd /tmp/$tempname # backup the original mail cat > mail # Get the signature munpack -q mail > /dev/null 2>&1 # Get the signed part boundary=`cat mail | grep boundary | sed -e "s/.*boundary=\"\(.*\)\".*/\1/" | sed -e "s/[\/+*]/./g" | head -1` cat mail | sed -e "1,/^--$boundary$/ d" -e "/^--$boundary$/,$ d" | sed -e "$ d" > signed # Check the signature echo "-----Output from GnuPG-----" > gpgoutput gpg --no-tty --verify part1 signed >> gpgoutput 2>&1 echo >> gpgoutput # Output new mail # Header cat mail | sed -e "/^$/,$ d" | grep -v "^[Content-|Lines]" | grep -v "protocol" # Mailbody and output from verification boundary=`cat signed | grep boundary | sed -e "s/.*boundary=\"\(.*\)\".*/\1/" | sed -e "s/[\/+*]/./g" | head -1` cat signed | awk "BEGIN {nummer=0} /^--$boundary\$/ {nummer++; if (nummer==2) {system(\"/bin/cat gpgoutput\")}} {print}" # Delete tempdir and files therein cd / rm -rf /tmp/$tempname
#!/bin/sh mail=`cat` echo "$mail" | sed -e "/^-----BEGIN PGP SIGNED MESSAGE/ d" -e "/^-----BEGIN PGP SIGNATURE/,$ d" echo "-----Output from GnuPG-----" echo "$mail" | /usr/bin/gpg --verify --no-tty 2>&1
msg23051/pgp00000.pgp
Description: PGP signature