commit 9908a6b96d8b5bfacf0e819734675f6bd23161bc
parent d1911d438ab4aa8b07b7f0c1f52e7f8f89ede505
Author: Hamish Downer <dmishd@gmail.com>
Date: Mon, 8 Nov 2010 22:31:01 +0000
catch exception when no public key present
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -247,19 +247,27 @@ private
end
def sig_output_lines signature
+ # It appears that the signature.to_s call can lead to a EOFError if
+ # the key is not found. So start by looking for the key.
+ ctx = GPGME::Ctx.new
+ begin
+ from_key = ctx.get_key(signature.fingerprint)
+ first_sig = signature.to_s.sub(/from [0-9A-F]{16} /, 'from "') + '"'
+ rescue EOFError => error
+ first_sig = "No public key available for #{signature.fingerprint}"
+ end
+
time_line = "Signature made " + signature.timestamp.strftime("%a %d %b %Y %H:%M:%S %Z") +
" using key ID " + signature.fingerprint[-8..-1]
- first_sig = signature.to_s.sub(/from [0-9A-F]{16} /, 'from "') + '"'
output_lines = [time_line, first_sig]
- ctx = GPGME::Ctx.new
- if from_key = ctx.get_key(signature.fingerprint)
+ if from_key
if from_key.uids.length > 1
aka_list = from_key.uids[1..-1]
aka_list.each { |aka| output_lines << ' aka "' + aka.uid + '"' }
end
end
- output_lines
+ output_lines.flatten!
end
# logic is: