New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import key #26
Comments
I have the same error when I try: ctx = GPGME::Ctx.new Was these a solution for this error? |
Because ruby-gpgme is a wrapper for the C code, the errors are sometimes obtuse and not immediately helpful. How was the key exported, as in, was it a GPGME export? Or is it from somewhere else? For example, OpenSSL keys can't be imported because the key formats are different. |
Update: I reinstalled pgpme with brew and after that the "Inappropriate ioctl for device" device error was gone. However, I ran into getting a empty string with, so I added decrypted.seek(0) per the other fix request. Is this still the most appropriate way to decrypt the file? require 'rubygems' encrypted_data = GPGME::Data.new(File.open("list.csv.pgp")) ctx = GPGME::Ctx.new :password=> thepassword' decrypted = ctx.decrypt encrypted_data File.write('list.csv', decrypted.read) |
Yeah, using the I tend to use keys in the keychain, so rather than importing the keys I specify the recipient when performing crypto functions. Here's a roundtrip example, and note that I wrote this for a console, the conf.echo = false # Stop IRB echoing everything, which errors with binary data
class PassphraseCallback
def initialize(passphrase)
@passphrase = passphrase
end
def call(*args)
fd = args.last
io = IO.for_fd(fd, 'w')
io.puts(@passphrase)
io.flush
end
end
# recipients can be found using $ gpg --list-keys --homedir ./keychain_location
# pub 2048R/A1B2C3D4 2014-01-17
# Use that line to substitute your own. 2048R is the key length and type (RSA in this case)
# If you want to substitute a non-default keychain into the engine do this:
# home_dir = Rails.root.join('keychain_location').to_s
# GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, '/usr/local/bin/gpg', home_dir)
# Note GPG executable location will change across platforms
crypto = GPGME::Crypto.new
options = {:recipients => 'A1B2C3D4'}
plaintext = GPGME::Data.new(File.open(Rails.root.join('Gemfile')))
data = crypto.encrypt plaintext, options
f = File.open(Rails.root.join('Gemfile.gpg'), 'wb')
bytes_written = f.write(data)
f.close
puts bytes_written
crypto = GPGME::Crypto.new
options = {:recipients => 'A1B2C3D4', :passphrase_callback => PassphraseCallback.new('my_passphrase')}
cipthertext = GPGME::Data.new(File.open(Rails.root.join('Gemfile.gpg')))
data = crypto.decrypt cipthertext, options
puts data |
Hello there, Ran into this problem today. It looks like it's something to do with the bundling/installing process of the gpgme gem and how it connects to the system gpg install. If you're seeing this error:
At least, that's what worked for me. |
I know the issue is not related to heroku stack.. but just wondering if someone can help me. The very same problem happens on new Heroku Cedar14 stack... whenever I try to do something like: Same does not happen on Heroku Cedar. Also had the same problem locally, but reinstalling gpg and the gem solved the issue. Not sure what to do from here.. |
+1 on having this issue with Cedar14 @andrehjr Were you able to solve it? |
@recurrence not yet.. we also tried different implementations, but new priorities came up.. One idea that one of the members of my team brought up was to use: If you try that and if it works, please let me know :) |
I tried a custom built gpgme and it also failed. I ended up using shell commands :) |
I don't know much about Heroku, but if it is sort of chroot, perhaps it might be failing in GPGME's use of ttyname_r: |
maybe the first step would be to isolate the problem between the gem and GPGME C library. since the library has a test case of --import, you can run it with:
|
Just tried |
I'm having this problem as well. I can confirm that it breaks in Cedar-14, but works perfectly fine in Cedar-10. My current guess is that the version of GPGME installed by ruby-gpgme needs to be changed here. Perhaps the versions of Does this sound like an avenue worth exploring? |
A correction: Circle CI has GPGME installed on their VMs, so I'm no longer confident that Ubuntu 12.04 is compatible with this gem (without reinstalling gpgme). I edited the above to reflect this. |
2.0.10 gem might fix the issue, as it contains gpgme 1.6.0, which has a fix to the ttyname_r error handling: |
👍 @ueno, upgrading to 2.0.10 on Heroku fixed the issue for me. |
Since this issue is still open .... Is it intended that |
I barely remember, but ruby-gpgme doesn't seem to export the |
@dansketcher Your comment was really helpful for my implementation and cleaner. I wished the GPGME github page provided clear example like that. thanks and Great work |
I'd completely forgotten I'd written this :) Now integrated into the Readme! |
Trying to do some decryption today however, I keep getting the password GUI prompt to enter the passphrase. Is there any way to bypass the password prompt |
Use GPGME 1.4, or a dummy pinentry program per #126 or see the note on the pinentry loopback in the same PR |
@adet4ever Setting the crypto = GPGME::Crypto.new(pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK) |
Leaving a comment here for future readers around the
|
I'm unable to import a key file. I'm using ruby 1.9.3-p448
running:
Output
I have gpg, MacGPGTools and gpg-agent installed on my system. Am I missing something?
The text was updated successfully, but these errors were encountered: