Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-28-2008, 10:58 AM   #1
LQ Newbie
Registered: May 2008
Posts: 2

Rep: Reputation: 0
GnuPG Decryption Protocol Error!

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:

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:

protocol error: expected DECRYPTION_OKAY got PLAINTEXT:
at ./ line 236

Contents of file xxxx_26867_21052008171501.txt.asc:

Version: McAfee E-Business Server v7.1.1 - Full License


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:

######  FOR TESTING PURPOSES ONLY ###################################################
sub test_encrypt  {

	my $gpg = new GnuPG();

	$gpg->encrypt (  plaintext => "", output => "", armor => 1,
                     recipient => "yyyyyyy", sign => 1, 
                     local_user	=> "yyyyyyy", passphrase => $GPG_PASSPHRASE);

        $gpg->decrypt (  ciphertext  => "",			output	=> "",
					 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.
Old 05-28-2008, 02:57 PM   #2
LQ Newbie
Registered: May 2008
Posts: 2

Original Poster
Rep: Reputation: 0

I finally broke down and decided to go the only route that I have read about when trying to fix this problem.

Apparently its a bug in the latter versions of GnuPG and requires a code change to the module. Instructions are found here:


I wasn't so sure this is the route I wanted to take. But due to the lack of any other solutions, I really had no other choice.

Just posting as a follow-up in case anyone else runs into this problem. It definitely has fixed my problem.
Old 05-30-2008, 04:43 AM   #3
Registered: May 2001
Posts: 29,394
Blog Entries: 55

Rep: Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566Reputation: 3566
Thanks for posting a fix follow-up.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
gnupg key generation error! gabsik Linux - Security 0 02-28-2008 09:08 PM
gnupg compile fatal error - how do I fix it? rkmason Linux - Software 3 06-07-2007 01:26 AM
Packman "Unknown GnuPG key" error erpe SUSE / openSUSE 1 12-09-2006 11:33 AM
PHP GnuPG encryption/decryption on a production webserver ahelis Programming 2 05-28-2006 12:14 AM
PHP GnuPG encryption/decryption rblampain Programming 5 08-12-2005 10:10 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration