Forum Moderators: coopster & phranque

Message Too Old, No Replies

GnuPG Module from the web

Works great on command line, dies from web

         

rocknbil

1:55 am on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is the task: using a gpg public key, encrypt data to be stored in a database. When the administrator goes to retrieve the data, they will UPLOAD their private key and enter the passphrase in a form. The data is extracted, the files (tmp files and private key) are deleted, and the decrypted output is printed to the browser.

Using the GnuPG perl module from the command line - all three functions - gen_key, encrypt, decrypt - work GREAT. From the web, can't get past encrypt.

When you drop some data in a form, it encrypts the data correctly but DIES. Pfft. The files are not deleted, nothing printed to output.

my $gpg = new GnuPG();
$gpg->encrypt (
recipient=>'This@that.com',
plaintext => '/path/to/original.txt',
output => '/path/to/encrypted_output_file.txt',
armor => 1,
passphrase => 'w00Hoo'
);

That's all there is to it. As I said, testing this from various angles it works GREAT on the cmd line but dies right after this, and ther's nothing superflous that could cause it.

Any ideas?

SeanW

9:25 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



Any reliance on environment variable? What about permissions? The web app will run as a different user -- make sure it can read/write all the places you are telling it to.

Sean

rocknbil

2:54 am on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Sean! Actually that was my first guess, it was an ownership issue. After spending almost an entire day working with our system admins on command line expiraments yesterday, I'm thinking it still is.

We expiramented with straight exec calls, etc., and had problems on and off until we verified that ALL the files invloved were owned by Apache. Once we did that it worked fine. Now I need to apply that to the calls to GnuPG.pm, because I'd really rather use that than some `rediculously long -a -n -d switch-ridden system call`! :D