Error decrypting in message using gpg in modperl script

2001-08-09 Thread Chris Pizzo

Anyone know why the decryption fails using gpg when run in a perl script in
a browser but works if run in a shell?  Here's the code sample:

my $cipher = TAG;
 -BEGIN PGP MESSAGE-

pvbhS8Q22VYPqn+4sitEw0bgTmDhPo6rruzsSJxCHLBUyTPrYaPlmelF2iADCpKD
IeqIOK0KZwRMHrXrlFir37i+2NzmNzcF4kidPKWuKSQe6ZNWs28=
=w+vi
-END PGP MESSAGE-
TAG
# Decode logic

$ENV{GNUPGHOME}=/usr/local/.gnupg;


my($PGP,$dbh,$sth,$pid,$recipient,$dat,@plaintext,@errs,$q,$r,$cc_no,$cc_exp
, $dbh1);

my($amount,$cc_no,$cc_exp,$c_name,$c_add,$c_city,$c_st,$c_zip,$c_country,$c_
type);

$PGP = /usr/bin/gpg --no-secmem-warning -dar;

$recipient = xx;

# Open a two-way pipe to pgp or gpg.
$pid = open3(\*PGP_WRITE, \*PGP_READ, \*PGP_ERR, $PGP $recipient);

unless ($pid) {
print Error: Could not open encryption program: $!;
exit;
}
# Send the plaintext to pgp/gpg

print PGP_WRITE $cipher;

close(PGP_WRITE);

# Read the ciphertext from PGP/gpg

@plaintext = PGP_READ;
close(PGP_READ);

# Read any error messages.

@errs = PGP_ERR;
close(PGP_ERR);
print @errs;

This is the Error:
gpg: decrypt_message failed: eof

Again it works fine in a shell but fails when run from the browser.  Any
help greatly appreiciated.

Chris




Re: Error decrypting in message using gpg in modperl script

2001-08-09 Thread Ron Savage

Chris

See below.

Cheers
Ron Savage
[EMAIL PROTECTED]
http://savage.net.au/index.html

 $PGP = /usr/bin/gpg --no-secmem-warning -dar;

Ahhh. Does the web server, running as 'nobody' (perhaps) have permission to run 'gpg'?





Re: Error decrypting in message using gpg in modperl script

2001-08-09 Thread Benjamin Trott

 Anyone know why the decryption fails using gpg when run in a perl script in
 a browser but works if run in a shell?  Here's the code sample:
 
 my $cipher = TAG;
 -BEGIN PGP MESSAGE-
 
 pvbhS8Q22VYPqn+4sitEw0bgTmDhPo6rruzsSJxCHLBUyTPrYaPlmelF2iADCpKD
 IeqIOK0KZwRMHrXrlFir37i+2NzmNzcF4kidPKWuKSQe6ZNWs28=
 =w+vi
 -END PGP MESSAGE-

This is not an answer to your question, but might I suggest (plug) using
Crypt::OpenPGP, my pure-Perl OpenPGP implementation? It will decrypt your
message, and it won't require launching an external shell etc.

use Crypt::OpenPGP:
my $pgp = Crypt::OpenPGP-new;
my $pt = $pgp-decrypt( Data = $cipher, Passphrase = $pass );

Here is a page w/ some more information:

http://rhumba.pair.com/ben/perl/openpgp/

If you have any problems let me know by mail.

bye,
Ben