I'm working on retrieving a PGP encrypted remote file from an ftp server, once the file is transferred I then go to decrypt the file. I am writing a Perl script to automate this decryption along with these other tasks.
I know my keys are properly set because I have been able to encrypt files using the script and command line, and decrypt using command line, but have NOT been able to decrypt using the Perl script. This error is really getting to me and would really appreciate any help. There seems to be VERY little out there about this specific issue.
Note, I am using GnuPG to handle the PGP encryption.
File to Decrypt:
xxxx_26867_21052008171501.txt.asc
Decrypt sub:
Code:
sub decrypt_file {
my $decrypt_fileName=@_[0];
my $gpg = new GnuPG( trace => 1);
my $output = substr($decrypt_fileName, 0, rindex($decrypt_fileName, "."));
$gpg->decrypt ( output => $output, ciphertext => $decrypt_fileName, passphrase => $GPG_PASSPHRASE);
}
The exact error I am getting:
Quote:
protocol error: expected DECRYPTION_OKAY got PLAINTEXT:
at ./xxxxxxx.pl line 236
|
Contents of file
xxxx_26867_21052008171501.txt.asc:
Quote:
-----BEGIN PGP MESSAGE-----
Version: McAfee E-Business Server v7.1.1 - Full License
a55^jh#2cnmpoiunvsampleencryptedcharshere
-----END PGP MESSAGE-----
|
Now, to test the BASIC functionality of the encrypt/decrypt to try and figure out the root of the problem, I created a test function. This function does a basic encrypt and decrypt of a basic test file. However, upon executing the script so it just runs this test function, it gives me the SAME error as above.
Below is the test function that I've tried to run:
Code:
###### FOR TESTING PURPOSES ONLY ###################################################
#
#
#
sub test_encrypt {
my $gpg = new GnuPG();
$gpg->encrypt ( plaintext => "xxxxx.pl", output => "TEST.pl.gpg", armor => 1,
recipient => "yyyyyyy", sign => 1,
local_user => "yyyyyyy", passphrase => $GPG_PASSPHRASE);
$gpg->decrypt ( ciphertext => "TEST.pl.gpg", output => "TEST.pl",
passphrase => $GPG_PASSPHRASE);
}
Keep in mind, a lot of substitutions were made for explicit file names and key ID's in the above code for obvious reasons.
Thank you for ANY help that you can provide. This really has stumped me for some time.