Python, CGI and PGP

Phil Edwards cuvy at yvahk2000.pbz
Mon Mar 25 18:58:24 EST 2002


I'm trying to get a CGI app working that is supposed to be able to produce 
PGP signed messages. The command line equivalent of what I'm trying to do 
in the CGI script would be:

/usr/local/bin/pgp -z mypassphrase -sta -f < /tmp/sometext.txt > 
/tmp/sometext.pgp 2>/dev/null

This works fine both at the CLI and in a bash script, and produces a text 
file with the '-----BEGIN PGP SIGNED MESSAGE-----' stuff at the top and the 
PGP signature stuff at the bottom.

My recent attempts at getting this to work in the CGI script have been to 
simply run the same command as above, but using either command.getoutput or 
os.system from within Python. Doing this, I get the PGP signature block 
that I would normally expect to see at the end of the message, but nothing 
else. I suspect that the problem is down to the different execution 
environment which PGP sees when it's being run within my CGI script, but 
I've not been able to find anything in the PGP docs that has helped.

I've done some research into this on the 'net, but I haven't been able to 
find any recent references to PGP usage within Python. Some guys were 
prototyping a PGP interface for Python 1.2 back in 1995, but there doesn't 
seem to have been any further work done since then. Is there currently a 
PGP module available anywhere? If not, can anybody point me in the 
direction of a site that is using PGP and Python?

FYI, my version of Python is 2.1, and my PGP version is 2.6.3 (don't ask - 
just don't, that's all...you'll just start me thinking about it all over 
again, and I'll probably start to hyperventilate...)

-- 

Phil Edwards
Brighton, UK
================================================
NB: E-Mail address is rot-13 encoded 
Sorry to be a pain, but I get enough spam already...
================================================



More information about the Python-list mailing list