Revision c99df77c
Added by Marc Dequènes over 15 years ago
- ID c99df77c83ec0afa6353277f7a8e9328cc0c844c
lib/tmail_gpg.rb | ||
---|---|---|
parts[1].content_type == "application/pgp-signature"
|
||
end
|
||
|
||
def pgp_signature
|
||
def pgp_signature_part
|
||
return nil unless is_pgp_signed?
|
||
parts[1].decoded
|
||
end
|
||
|
||
def pgp_signature
|
||
return nil unless is_pgp_signed?
|
||
parts[1].body
|
||
end
|
||
|
||
def pgp_signed_part
|
||
return nil unless is_pgp_signed?
|
||
parts[0]
|
||
... | ... | |
:passphrase_callback_value => passphrase_callback, :armor => true})
|
||
gpg.add_signer(*signers)
|
||
sig_data = GPGME::Data.new
|
||
gpg.sign(GPGME::Data.new(self.to_rfc3156), sig_data, GPGME::SIG_MODE_NORMAL)
|
||
# adds a final CRLF to respect OpenPGP convention (see note in chapter 5 of RFC3156)
|
||
prepared_data = self.to_rfc3156 + "\r\n"
|
||
gpg.sign(GPGME::Data.new(prepared_data), sig_data, GPGME::SIG_MODE_DETACH)
|
||
hash_algo = GPGME.gpgme_op_sign_result(gpg).signatures.first.hash_algo
|
||
micalg = "pgp-" + GPGME.gpgme_hash_algo_name(hash_algo).downcase
|
||
sig_data.seek(0, IO::SEEK_SET)
|
||
|
||
{:signature => sig_data.read, :micalg => micalg}
|
||
end
|
||
|
||
... | ... | |
|
||
def copy_headers_from(mail)
|
||
mail.header.keys.each do |h|
|
||
self[h] = mail[h].to_s
|
||
#if mail[h].is_a? Array
|
||
# list = []
|
||
# mail[h].each {|d| list << d.to_s }
|
||
# self[h] = list
|
||
#else
|
||
self[h] = mail[h].to_s
|
||
#end
|
||
end
|
||
end
|
||
|
||
... | ... | |
begin
|
||
require 'gpgme' # >= 1.0.2 needed for :always_trust sign option
|
||
TMail::Mail.send(:include, TMail::GpgExtension)
|
||
rescue
|
||
rescue LoadError
|
||
end
|
Also available in: Unified diff
[fix] updated the TMail extension