ueno/ruby-gpgme

GeneralError raised when Crypto.new.encrypt(...) with fingerprint

Closed this issue · 1 comments

When using fingerprints of sender and recipient as argument for the Crypto.new.encrypt(....) as signers and recipients, it throws GeneralError and I do not know how to solve this.

        GPGME::Engine.home_dir = dir
        
        recipient_fingerprint =
          GPGME::Key.import(recipient_pubkey).imports[0].fpr \
            || raise("Nil recipient fingerprint from import")
        sender_fingerprint =
          GPGME::Key.import(sender_privkey).imports[0].fpr \
            || raise("Nil sender fingerprint from import")

        puts
        puts "signers: [#{sender_fingerprint}]"
        puts "recipients: [#{recipient_fingerprint}]"

        crypto = GPGME::Crypto
          .new(:pinentry_mode => GPGME::PINENTRY_MODE_LOOPBACK)
          .encrypt(
            plaintext,
            sign:         true,
            signers:      [sender_fingerprint],
            recipients:   [recipient_fingerprint],
            always_trust: true,
          )

Any help is appreciated. thanks

Note:

- gpg version: 2.1.21

# Gemfile
- gem 'gpgme', '~> 2.0', '>= 2.0.12'

Uh... this was due to lack of my understaning on the gpg key exchange algorithm. now it has been solved that i will close this.