blob: 1841809be7706e834c6141154dc667f31966c7ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module Mail
class Message
def signatures
boundary = content_type._?.match(/boundary="?([^;"]*)"?;?/)._?.captures._?.first
return [] unless boundary
boundary = Regexp.escape(boundary)
signed = body.decoded.match(/#{boundary}\n(.*?)\n\-*#{boundary}/m)._?.captures._?.first
return [] unless signed
result = []
for part in parts[1..-1]
begin
GPGME::verify(part.decoded, signed){ |signature| result.push signature.to_s}
rescue
# Some signatures break GPGME::Signature#to_s - report them
result = []
GPGME::verify(part.decoded, signed) do |signature|
result.push "Breaking signature"
end
end
end
result
end
end
end
|