mail-gpg 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mail/gpg.rb CHANGED
@@ -15,13 +15,13 @@ require 'mail/gpg/sign_part'
15
15
  module Mail
16
16
  module Gpg
17
17
  # options are:
18
- # :sign : sign message using the sender's private key
19
- # :sign_as : sign using this key (give the corresponding email address)
18
+ # :sign: sign message using the sender's private key
19
+ # :sign_as: sign using this key (give the corresponding email address or key fingerprint)
20
20
  # :passphrase: passphrase for the signing key
21
- # :keys : A hash mapping recipient email addresses to public keys or public
21
+ # :keys: A hash mapping recipient email addresses to public keys or public
22
22
  # key ids. Imports any keys given here that are not already part of the
23
23
  # local keychain before sending the mail.
24
- # :always_trust : send encrypted mail to untrusted receivers, true by default
24
+ # :always_trust: send encrypted mail to untrusted receivers, true by default
25
25
  def self.encrypt(cleartext_mail, options = {})
26
26
  construct_mail(cleartext_mail, options) do
27
27
  receivers = []
@@ -18,7 +18,7 @@ module Mail
18
18
  begin
19
19
  if options[:sign]
20
20
  if options[:signers]
21
- signers = GPGME::Key.find(:public, options[:signers], :sign)
21
+ signers = GPGME::Key.find(:secret, options[:signers], :sign)
22
22
  ctx.add_signer(*signers)
23
23
  end
24
24
  ctx.encrypt_sign(recipient_keys, plain_data, cipher_data, flags)
@@ -1,16 +1,17 @@
1
1
  module Mail
2
- module Gpg
3
- class SignPart < Mail::Part
2
+ module Gpg
3
+ class SignPart < Mail::Part
4
4
 
5
- def initialize(cleartext_mail, options = {})
6
- signature = GpgmeHelper.sign(cleartext_mail.encoded, options)
7
- super() do
8
- body signature.to_s
9
- content_type "application/pgp-signature; name=\"signature.asc\""
10
- content_disposition 'attachment; filename="signature.asc"'
11
- content_description 'OpenPGP digital signature'
12
- end
13
- end
14
- end
15
- end
5
+ def initialize(cleartext_mail, options = {})
6
+ signature = GpgmeHelper.sign(cleartext_mail.encoded, options)
7
+ super() do
8
+ body signature.to_s
9
+ content_type "application/pgp-signature; name=\"signature.asc\""
10
+ content_disposition 'attachment; filename="signature.asc"'
11
+ content_description 'OpenPGP digital signature'
12
+ end
13
+ end
14
+
15
+ end
16
+ end
16
17
  end
@@ -1,5 +1,5 @@
1
1
  module Mail
2
2
  module Gpg
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/test/gpg_test.rb CHANGED
@@ -52,8 +52,15 @@ class GpgTest < Test::Unit::TestCase
52
52
 
53
53
  context "gpg installation" do
54
54
  should "have keys for jane and joe" do
55
- assert joe = GPGME::Key.find(:public, 'joe@foo.bar').first
56
- assert jane = GPGME::Key.find(:public, 'jane@foo.bar').first
55
+ assert joe = GPGME::Key.find(:public, 'joe@foo.bar')
56
+ assert_equal 1, joe.size
57
+ joe = joe.first
58
+ assert jane = GPGME::Key.find(:public, 'jane@foo.bar')
59
+ assert_equal 1, jane.size
60
+ jane = jane.first
61
+ assert id = jane.fingerprint
62
+ assert jane = GPGME::Key.find(:public, id).first
63
+ assert_equal id, jane.fingerprint
57
64
  end
58
65
  end
59
66
 
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-14 00:00:00.000000000 Z
12
+ date: 2013-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mail