ueno / ruby-gpgme

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

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

Closed keitaroemotion closed 7 years ago

keitaroemotion commented 7 years ago

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'
keitaroemotion commented 7 years ago

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.