ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

GPGME::Error::NoData when using Heroku #170

Closed heitortoledo closed 1 year ago

heitortoledo commented 1 year ago

Hey, I'm having an issue when I try to decrypt an encrypted file on a Heroku server, when the decrypt method is called by the GPGME::Crypto instance it raises a GPGME::Error::NoData error. The error occurs only when it's on Heroku, when I test locally on my development environment, it works just fine.

Home: /app/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2


- Stack trace
```ruby
#vendor/bundle/ruby/2.6.0/gems/gpgme-2.0.20/lib/gpgme/ctx.rb:435 decrypt_verify
    def decrypt_verify(cipher, plain = Data.new)
      err = GPGME::gpgme_op_decrypt_verify(self, cipher, plain)
      exc = GPGME::error_to_exception(err)
      raise exc if exc
      plain
    end

#vendor/bundle/ruby/2.6.0/gems/gpgme-2.0.20/lib/gpgme/crypto.rb:172 block in decrypt
      GPGME::Ctx.new(options) do |ctx|
        begin
          ctx.decrypt_verify(cipher_data, plain_data)
        rescue GPGME::Error::UnsupportedAlgorithm => exc
          exc.algorithm = ctx.decrypt_result.unsupported_algorithm
          raise exc

#vendor/bundle/ruby/2.6.0/gems/gpgme-2.0.20/lib/gpgme/ctx.rb:79 new
      if block_given?
        begin
          yield ctx
        ensure
          GPGME::gpgme_release(ctx)
        end

#vendor/bundle/ruby/2.6.0/gems/gpgme-2.0.20/lib/gpgme/crypto.rb:170 decrypt
      plain_data   = Data.new(options[:output])
      cipher_data  = Data.new(cipher)
      GPGME::Ctx.new(options) do |ctx|
        begin
          ctx.decrypt_verify(cipher_data, plain_data)
        rescue GPGME::Error::UnsupportedAlgorithm => exc

#lib/modules/file_decrypt.rb:8 decrypt
    crypto = GPGME::Crypto.new
    options = { output: File.open(output_file, 'wb'), pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK,
                password: ENV['PASSPHRASE'] }
    crypto.decrypt(File.open(file.local), options)
    output_file
  end