[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - GPG verify script

GPG verify script

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

GPG verify script

Postby chgerwig » Thu Sep 09, 2004 7:34 pm

Hi all,

Robin asked me to post my GPG verify script here. I am working with it for about half a year without problems. But still I cannot give any warranty that it will work with all installations or Windows versions. I run it on Win2k German and PocoMail 3.1 and 3.03 German.

The Script verifies if a GPG signature or encrytion is in the message. If there is a signature it checkes it against the local keyring. If the key is not there GPG tries to get it from the keyserver. The then result of this check ist attached to the end of the message, where you can see if the signature is good or bad.
If it is encrypted a DOS-window opens and you have to type in the password to encrypt it. Then the decrypted text is replaced in the message.

The script needs a little batch file which follows later.

DON NOT FORGET TO CHECK THE PATHS IN BOTH FILES!

Here ist the Script:
Code: Select all
{### GnuPG (Version 1.2.4) decrypt verify Email body
{ by Christian Gerwig 10.03.04
{ Script will check the message - also HTML - if PGP encryption
{ or signature is in it.
{ For encryption it will decrypt the message
{ For signature it will verify the signature against the pub keyring
{
{ ATTENTION: Needs pgpverify.bat in Scripts folder
{ !!! Check the paths here and in the batch file !!!

ReadRawBody $a %message
if "-----BEGIN PGP SIGNED" ^ $a  then verify
if "-----BEGIN PGP" ^ $a  then decrypt
Exit

:decrypt
ReadBody $a %message
SaveBody $a "c:\programme\pocomail3\scripts\message.gpg"
Set $command "-o c:\programme\pocomail3\scripts\message.asc "
AddStrings $command "--decrypt c:\programme\pocomail3\scripts\message.gpg"
ExecuteAndWait "c:\programme\gnupg\gpg.exe" $command
OpenBody $a "c:\programme\pocomail3\scripts\message.asc"
AssignBody %message $a
DeleteFile "c:\Programme\pocomail3\scripts\message.gpg"
DeleteFile "c:\Programme\pocomail3\scripts\message.asc"
Exit

:verify
ReadRawBody $a %message
SaveBody $a "c:\Programme\pocomail3\scripts\message.sig"
ExecuteAndWait "c:\Programme\pocomail3\scripts\gpgverify.bat" "c:\Programme\pocomail3\scripts\message.sig 2> c:\Programme\pocomail3\scripts\result.txt"
AppendBody $a "+++++ Result from GnuPG: +++++"
OpenBody $r "c:\Programme\pocomail3\scripts\result.txt"
AppendBody $a $r
AppendBody $a "+++++ End Result GnuPG +++++"
AssignBody %message $a
DeleteFile "c:\Programme\pocomail3\scripts\message.sig"
DeleteFile "c:\Programme\pocomail3\scripts\result.txt"
Exit


Content of gpgverify.bat:
Code: Select all
c:\programme\gnupg\gpg -o c:\programme\pocomail3\scripts\message.asc --verify %1


I hope you find this helpful.
Bye,
Christian
------------
Reseller of PocoMail in Austria
chgerwig
Poco Tourist
 
Posts: 17
Joined: Tue Aug 24, 2004 12:27 am
Location: Vienna, Austria

Postby robin » Thu Sep 09, 2004 8:34 pm

Thanks Christian!
robin
 

Postby Michael » Fri Sep 10, 2004 2:14 am

One suggestion here, use the $scriptpath system variable to construct the file names. For example:
Code: Select all
AddStrings $GPGFile $ScriptPath message.gpg
SaveBody $a $GPGFile


Use this throughout the script and you'll avoid the problems of users having to manually convert the paths. You will also make it possible to run this script in beta versions if you install them to different directories.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby chgerwig » Sun Sep 12, 2004 7:22 pm

Thanks for the comments and hints, Michael!
I learned something and I will change my script.
Bye,
Christian
------------
Reseller of PocoMail in Austria
chgerwig
Poco Tourist
 
Posts: 17
Joined: Tue Aug 24, 2004 12:27 am
Location: Vienna, Austria


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron