GPGME::Error::BadPassphrase when using decrypt without pinentry dialog box

Jim Evans's Avatar

Jim Evans

04 Jun, 2015 02:15 PM

Steps to reproduce:
Run bundle exec rails c
Run the following
crypto = GPGME::Crypto.new :armor=>true
decrypted_object = crypto.decrypt(encrypted_data, :password => my_password)
The Pinentry Mac dialog box appears as expected
Copy my password from my_password and paste into dialog box.
Text is decrypted as expected.
Exit the rails console.
Open up ~/.gnupg/gpg-agent.conf
and add
pinentry-program /usr/bin/pinentry-curses
to avoid having that dialog box come up
Save and close
Run echo RELOADAGENT | gpg-connect-agent to load the change
Run bundle exec rails c
run the following (same as above)
crypto = GPGME::Crypto.new :armor=>true
decrypted_object = crypto.decrypt(encrypted_data, :password => my_password)
Now I get the error:
GPGME::Error::BadPassphrase: GPGME::Error::BadPassphrase
from /Users/USERNAME/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gpgme-2.0.8/lib/gpgme/ctx.rb:398:in decrypt_verify' from /Users/USERNAME/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gpgme-2.0.8/lib/gpgme/crypto.rb:172:inblock in decrypt'
from /Users/USERNAME/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gpgme-2.0.8/lib/gpgme/ctx.rb:71:in new' from /Users/USERNAME/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/gpgme-2.0.8/lib/gpgme/crypto.rb:170:indecrypt'

Research indicates I'm using an incompatible version of gnupg, i.e. 2.0., however:
gpg --version gives:
gpg (GnuPG) 1.4.19
Home: ~/.gnupg
and gpg2 --version gives:
gpg (GnuPG) 2.1.4
libgcrypt 1.6.3
Home: ~/.gnupg

And finally, GPGME::Engine.info gives:
#GPGME::EngineInfo:0x007fe4b8e8d2e0 @protocol=0, @file_name="/usr/local/bin/gpg2", @version="2.1.4", @req_version="1.4.0", #GPGME::EngineInfo:0x007fe4b8e8d218 @protocol=1, @file_name="/usr/local/bin/gpgsm", @version="2.1.4", @req_version="2.0.4", #GPGME::EngineInfo:0x007fe4b8e8d178 @protocol=2, @file_name="/usr/local/bin/gpgconf", @version="2.1.4", @req_version="2.0.4", #GPGME::EngineInfo:0x007fe4b8e8d0d8 @protocol=3, @file_name="/Users/jevans/.gnupg/S.gpg-agent", @version="1.0", @req_version="1.0", @home_dir="!GPG_AGENT", #GPGME::EngineInfo:0x007fe4b8e8d010 @protocol=6, @file_name="/nonexistent", @version="1.0", @req_version="1.0"

Other info:
Mac 10.10.3
Installed GPG Tools - GPG Suite Beta 6 (gnupg 2.0.27)
Installed gpg2 via make
Installed gpg 1.4 via brew

Soo.....Any guidance on how to use the passphrase via the script rather than via the dialog box?

  1. Support Staff 1 Posted by Luke Le on 17 Jul, 2015 05:36 PM

    Luke Le's Avatar

    Hi Jim,

    seeing that one of your versions is 2.1.x it's very much possible that you'll need to tweak your gpg.conf with pinentry options. As far as I remember there have been quite a few changes in regards to pinentry (search for pinentry-loopback)
    Also you might have to make sure that your version of GPGME supports 2.1.x

    I'd recommend temporarily disabling/removing any gpg versions besides 2.0.x and trying if it works then.

  2. Support Staff 2 Posted by Steve on 24 Feb, 2016 12:15 PM

    Steve's Avatar

    Closing, since no further user feedback was received. Should your problem persist, feel free to re-open this discussion any time.

    All the best, steve

  3. Steve closed this discussion on 24 Feb, 2016 12:15 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac