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 = "xxxxxx";

        # 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

Reply via email to