mail-gpg 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -7
- data/History.txt +7 -0
- data/README.md +36 -0
- data/lib/mail/gpg.rb +5 -5
- data/lib/mail/gpg/inline_decrypted_message.rb +3 -3
- data/lib/mail/gpg/inline_signed_message.rb +3 -3
- data/lib/mail/gpg/mime_signed_message.rb +2 -2
- data/lib/mail/gpg/rails.rb +2 -0
- data/lib/mail/gpg/rails/action_mailer_base_patch.rb +14 -17
- data/lib/mail/gpg/version.rb +1 -1
- data/test/gpg_test.rb +1 -1
- data/test/gpghome/pubring.gpg +0 -0
- data/test/gpghome/pubring.gpg~ +0 -0
- data/test/message_test.rb +10 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 078f6ded49865b4d9209f3287fc4a8847c93c440
|
4
|
+
data.tar.gz: 4933780b91d6e63c20f471f011dd27bdc8ad0552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 001a1eff43c868d332d3f88e880ffff134cc42dfe357e709172bc729049a3ca1e44037971781fc9a62480ca0deed913b842105ed22be78347060ffa8d05ffccd
|
7
|
+
data.tar.gz: c6da2c51dd13d9d119d8247a34876a30d0928f76f862cde51f93203872e20587f2bcf1df6480526aafb891767f6ca1ec4a6a394dddbe886b261ef77c00b511ec
|
data/.travis.yml
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 1.9.3
|
3
|
+
- 2.3.1
|
4
|
+
- 2.2.5
|
5
|
+
- 2.1.9
|
7
6
|
env:
|
8
|
-
- RAILS=3.2.
|
9
|
-
- RAILS=4.1.
|
10
|
-
- RAILS=4.2.1
|
7
|
+
- RAILS=3.2.22.1
|
8
|
+
- RAILS=4.1.14.1
|
9
|
+
- RAILS=4.2.5.1
|
10
|
+
- RAILS=5.0.0.1
|
11
|
+
matrix:
|
12
|
+
exclude:
|
13
|
+
- rvm: 2.1.9
|
14
|
+
env: RAILS=5.0.0.1
|
15
|
+
before_install:
|
16
|
+
- gem update bundler
|
17
|
+
sudo: false
|
18
|
+
cache: bundler
|
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.2.7 2016-09-28
|
2
|
+
|
3
|
+
* fix replying to message objects #35
|
4
|
+
* remove usage of deprecated alias_method_chain
|
5
|
+
* fix tests with Rails >= 4
|
6
|
+
* run tests with Rails 5, bump versions in travis config
|
7
|
+
|
1
8
|
== 0.2.6 2015-10-20
|
2
9
|
|
3
10
|
* fix handling of inline encrypted messages
|
data/README.md
CHANGED
@@ -184,6 +184,42 @@ hkp.fetch_and_import(id)
|
|
184
184
|
The gpg option takes the same arguments as outlined above for the
|
185
185
|
Mail::Message#gpg method.
|
186
186
|
|
187
|
+
|
188
|
+
## Passwords and GnuPG versions >= 2.x
|
189
|
+
|
190
|
+
GnuPG versions >= 2.x require the use of gpg-agent for key-handling. That's a problem for using password-protected keys non-interactively, because gpg-agent doesn't read from file-descriptors (which is the usual way to non-interactively provide passwords with GnuPG 1.x).
|
191
|
+
|
192
|
+
With GnuPG 2.x you have two options to provide passwords to gpg-agent:
|
193
|
+
|
194
|
+
1. Implement a pinentry-kind-of program that speaks the assuan-protocol and configure gpg-agent to use it.
|
195
|
+
2. Run gpg-preset-passphrase and allow gpg-agent to read preset passwords.
|
196
|
+
|
197
|
+
The second options is somewhat easier and is described below.
|
198
|
+
|
199
|
+
Note: You *don't* need this if your key is *not* protected with a password.
|
200
|
+
|
201
|
+
|
202
|
+
To feed a password into gpg-agent run this code early in your program:
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
# The next two lines need adaption, obviously.
|
206
|
+
fpr = fingerprint_of_key_to_unlock
|
207
|
+
passphrase = gpg_passphrase_for_key
|
208
|
+
# You may copy&paste the rest of this block unchanged. Maybe you want to change the error-handling, though.
|
209
|
+
ENV['GPG_AGENT_INFO'] = `eval $(gpg-agent --allow-preset-passphrase --daemon) && echo $GPG_AGENT_INFO`
|
210
|
+
`gpgconf --list-dir`.match(/libexecdir:(.*)/)
|
211
|
+
gppbin = File.join($1, 'gpg-preset-passphrase')
|
212
|
+
Open3.popen3(gppbin, '--preset', fpr) do |stdin, stdout, stderr|
|
213
|
+
stdin.puts passphrase
|
214
|
+
err = stderr.readlines
|
215
|
+
$stderr.puts err if ! err.to_s.empty?
|
216
|
+
end
|
217
|
+
# Hook to kill our gpg-agent when script finishes.
|
218
|
+
Signal.trap(0, proc { Process.kill('TERM', ENV['GPG_AGENT_INFO'].split(':')[1]) })
|
219
|
+
|
220
|
+
```
|
221
|
+
|
222
|
+
|
187
223
|
## Running the tests
|
188
224
|
|
189
225
|
bundle exec rake
|
data/lib/mail/gpg.rb
CHANGED
@@ -101,7 +101,7 @@ module Mail
|
|
101
101
|
end
|
102
102
|
|
103
103
|
STANDARD_HEADERS = %w(from to cc bcc reply_to subject in_reply_to return_path message_id)
|
104
|
-
MORE_HEADERS = %w(Auto-Submitted
|
104
|
+
MORE_HEADERS = %w(Auto-Submitted OpenPGP References)
|
105
105
|
|
106
106
|
private
|
107
107
|
|
@@ -117,7 +117,7 @@ module Mail
|
|
117
117
|
header['Message-ID'] = cleartext_mail['Message-ID'].value
|
118
118
|
end
|
119
119
|
cleartext_mail.header.fields.each do |field|
|
120
|
-
if MORE_HEADERS.include?(field.name) or field.name =~ /^X-/
|
120
|
+
if MORE_HEADERS.include?(field.name) or field.name =~ /^(List|X)-/
|
121
121
|
header[field.name] = field.value
|
122
122
|
end
|
123
123
|
end
|
@@ -151,14 +151,14 @@ module Mail
|
|
151
151
|
|
152
152
|
# decrypts inline PGP encrypted mail
|
153
153
|
def self.decrypt_pgp_inline(encrypted_mail, options)
|
154
|
-
InlineDecryptedMessage.
|
154
|
+
InlineDecryptedMessage.setup(encrypted_mail, options)
|
155
155
|
end
|
156
156
|
|
157
157
|
def self.verify(signed_mail, options = {})
|
158
158
|
if signed_mime?(signed_mail)
|
159
|
-
Mail::Gpg::MimeSignedMessage.
|
159
|
+
Mail::Gpg::MimeSignedMessage.setup signed_mail, options
|
160
160
|
elsif signed_inline?(signed_mail)
|
161
|
-
Mail::Gpg::InlineSignedMessage.
|
161
|
+
Mail::Gpg::InlineSignedMessage.setup signed_mail, options
|
162
162
|
else
|
163
163
|
signed_mail
|
164
164
|
end
|
@@ -12,9 +12,9 @@ module Mail
|
|
12
12
|
# options are:
|
13
13
|
#
|
14
14
|
# :verify: decrypt and verify
|
15
|
-
def
|
15
|
+
def self.setup(cipher_mail, options = {})
|
16
16
|
if cipher_mail.multipart?
|
17
|
-
|
17
|
+
self.new do
|
18
18
|
cipher_mail.header.fields.each do |field|
|
19
19
|
header[field.name] = field.value
|
20
20
|
end
|
@@ -48,7 +48,7 @@ module Mail
|
|
48
48
|
end # of multipart
|
49
49
|
else
|
50
50
|
decrypted = cipher_mail.body.empty? ? '' : GpgmeHelper.decrypt(cipher_mail.body.decoded, options)
|
51
|
-
|
51
|
+
self.new do
|
52
52
|
cipher_mail.header.fields.each do |field|
|
53
53
|
header[field.name] = field.value
|
54
54
|
end
|
@@ -4,9 +4,9 @@ module Mail
|
|
4
4
|
module Gpg
|
5
5
|
class InlineSignedMessage < Mail::Message
|
6
6
|
|
7
|
-
def
|
7
|
+
def self.setup(signed_mail, options = {})
|
8
8
|
if signed_mail.multipart?
|
9
|
-
|
9
|
+
self.new do
|
10
10
|
global_verify_result = []
|
11
11
|
signed_mail.header.fields.each do |field|
|
12
12
|
header[field.name] = field.value
|
@@ -29,7 +29,7 @@ module Mail
|
|
29
29
|
verify_result global_verify_result
|
30
30
|
end # of multipart
|
31
31
|
else
|
32
|
-
|
32
|
+
self.new do
|
33
33
|
signed_mail.header.fields.each do |field|
|
34
34
|
header[field.name] = field.value
|
35
35
|
end
|
@@ -4,10 +4,10 @@ module Mail
|
|
4
4
|
module Gpg
|
5
5
|
class MimeSignedMessage < Mail::Message
|
6
6
|
|
7
|
-
def
|
7
|
+
def self.setup(signed_mail, options = {})
|
8
8
|
content_part, signature = signed_mail.parts
|
9
9
|
success, vr = SignPart.verify_signature(content_part, signature, options)
|
10
|
-
|
10
|
+
self.new do
|
11
11
|
verify_result vr
|
12
12
|
signed_mail.header.fields.each do |field|
|
13
13
|
header[field.name] = field.value
|
data/lib/mail/gpg/rails.rb
CHANGED
@@ -5,28 +5,29 @@ module Mail
|
|
5
5
|
module Rails
|
6
6
|
|
7
7
|
module ActionMailerPatch
|
8
|
-
extend ActiveSupport::Concern
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def self.apply
|
10
|
+
unless ActionMailer::Base < InstanceMethods
|
11
|
+
ActionMailer::Base.prepend InstanceMethods
|
12
|
+
ActionMailer::Base.singleton_class.prepend ClassMethods
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
headers =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
module InstanceMethods
|
17
|
+
def mail(headers = {}, &block)
|
18
|
+
headers = headers.dup
|
19
|
+
gpg_options = headers.delete :gpg
|
20
|
+
super(headers, &block).tap do |m|
|
21
|
+
if gpg_options
|
22
|
+
m.gpg gpg_options
|
23
|
+
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
module ClassMethods
|
28
|
-
def
|
29
|
-
|
29
|
+
def deliver_mail(mail, &block)
|
30
|
+
super(mail) do
|
30
31
|
Mail::Gpg::DeliveryHandler.deliver_mail mail, &block
|
31
32
|
end
|
32
33
|
end
|
@@ -34,10 +35,6 @@ module Mail
|
|
34
35
|
|
35
36
|
end
|
36
37
|
|
37
|
-
unless ActionMailer::Base.included_modules.include?(ActionMailerPatch)
|
38
|
-
ActionMailer::Base.send :include, ActionMailerPatch
|
39
|
-
end
|
40
|
-
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
data/lib/mail/gpg/version.rb
CHANGED
data/test/gpg_test.rb
CHANGED
@@ -14,7 +14,7 @@ class GpgTest < Test::Unit::TestCase
|
|
14
14
|
v_part, enc_part = encrypted.parts
|
15
15
|
|
16
16
|
assert_match /Version: 1/, v_part.to_s
|
17
|
-
|
17
|
+
assert_match /application\/pgp-encrypted(?:; charset=UTF-8)?/, v_part.content_type
|
18
18
|
|
19
19
|
assert_equal 'application/octet-stream; name=encrypted.asc',
|
20
20
|
enc_part.content_type
|
data/test/gpghome/pubring.gpg
CHANGED
Binary file
|
data/test/gpghome/pubring.gpg~
CHANGED
Binary file
|
data/test/message_test.rb
CHANGED
@@ -74,13 +74,23 @@ class MessageTest < Test::Unit::TestCase
|
|
74
74
|
context "" do
|
75
75
|
setup do
|
76
76
|
@mail.header['Auto-Submitted'] = 'foo'
|
77
|
+
@mail.header['List-Help'] = 'https://lists.example.org/help/'
|
78
|
+
@mail.header['List-Id'] = 'test.lists.example.org'
|
79
|
+
@mail.header['List-Owner'] = 'test-owner@lists.example.org'
|
80
|
+
@mail.header['List-Post'] = '<mailto:test@lists.example.org> (Subscribers only)'
|
77
81
|
@mail.header['List-Unsubscribe'] = 'bar'
|
82
|
+
@mail.header['OpenPGP'] = 'id=0x0123456789abcdef0123456789abcdefdeadbeef (present on keyservers); (Only encrypted and signed emails are accepted)'
|
78
83
|
@mail.deliver
|
79
84
|
end
|
80
85
|
|
81
86
|
should 'keep custom header value' do
|
82
87
|
assert_equal 'foo', @mails.first.header['Auto-Submitted'].value
|
88
|
+
assert_equal 'https://lists.example.org/help/', @mails.first.header['List-Help'].value
|
89
|
+
assert_equal 'test.lists.example.org', @mails.first.header['List-Id'].value
|
90
|
+
assert_equal 'test-owner@lists.example.org', @mails.first.header['List-Owner'].value
|
91
|
+
assert_equal '<mailto:test@lists.example.org> (Subscribers only)', @mails.first.header['List-Post'].value
|
83
92
|
assert_equal 'bar', @mails.first.header['List-Unsubscribe'].value
|
93
|
+
assert_equal 'id=0x0123456789abcdef0123456789abcdefdeadbeef (present on keyservers); (Only encrypted and signed emails are accepted)', @mails.first.header['OpenPGP'].value
|
84
94
|
end
|
85
95
|
|
86
96
|
should "deliver signed mail" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-gpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Kraemer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -229,4 +229,3 @@ test_files:
|
|
229
229
|
- test/sign_part_test.rb
|
230
230
|
- test/test_helper.rb
|
231
231
|
- test/version_part_test.rb
|
232
|
-
has_rdoc:
|