Set the :verify option to true when calling decrypt to decrypt and verify signatures.Ī GPGME::Error::BadPassphrase will be raised if the password for the private key is incorrect.Ī EncodingError will be raised if the encrypted mails is not encoded correctly as a RFC 3156 message. decrypt ( :password => 'abc' ) # the plaintext_mail, is a full Mail::Message object, just decrypted end encrypted? # decrypt using your private key, protected by the given passphrase plaintext_mail = mail. subject # subject is never encrypted if mail. Get a decrypted version of the mail with the decrypt method: Check if it is encrypted using the encrypted? method. You may also want to have a look at the GPGME docs and code base for more info on the various options, especially regarding the passphrase_callback arguments. Keys already present in the local keychain forĪny of the recipients that are not explicitly mentioned in the keys hash will If it is present, only key material from there (either given as key data likeĪbove, or as key id, key fingerprint or GPGMe::Key object if they have been Note: Mail-Gpg in version 0.4 and up is more strict regarding the keys option: In theory you only need to specify the key once like that, however doing itĮvery time does not hurt as gpg is clever enough to recognize known keys, only The key will then be imported before actually trying to encrypt/send the mail. If you collect public key data from your users, you can specify the asciiĪrmored key data for recipients using the :keys option like this: You will get errors in case encryption is not possible due to missing keys. Make sure all recipients' public keys are present in your local gpg keychain. gpg encrypt: true, sign_as:, passphrase_callback: -> ( obj, uid_hint, passphrase_info, prev_was_bad, fd ) end. new do to from subject 'gpg test' body "encrypt me!" add_file "some_attachment.zip" # encrypt message, no signing gpg encrypt: true # encrypt and sign message with sender's private key, using the given # passphrase to decrypt the key gpg encrypt: true, sign: true, password: 'secret' # encrypt and sign message using a different key gpg encrypt: true, sign_as:, password: 'secret' # encrypt and sign message and use a callback function to provide the # passphrase.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |