In the example below, I tried the password and passphrase. I am also not allowed to run my code without the openpgp field requesting a passphrase, the following message:
Mac syntax "Please enter a passphrase to unlock the secret key for an OpenPGP certificate"
What do I need to change so that my code can work without a hint? I know that my password is correct in the code.
I tried:
ctx = GPGME::Ctx.new :password=> 'password'
and this:
ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc)
But both do not work. Any advice is appreciated.
def self.passfunc(obj, uid_hint, passphrase_info, prev_was_bad, fd)
io = IO.for_fd(fd, 'w')
io.puts 'password'
io.flush
end
def self.decrypt_file(local_file, decrypted_file = nil)
decrypted_file = local_file.chomp(File.extname(local_file)) + ".csv" if decrypted_file == nil
encrypted_data = GPGME::Data.new(File.open(local_file))
ctx = GPGME::Ctx.new :password=> 'password'
ctx.import_keys Rebal::Config::KEY
decrypted = ctx.decrypt encrypted_data
decrypted.seek(0)
File.write(decrypted_file, decrypted.read)
decrypted_file
end
, , ...
ruby gpgme
, , soltuion...
pinentry ( ) gpgme - , , .
: , pinentry GPG2 GPG1.4. GPG1.4, .
- , GPG2 ,