Try to handle binary signature

This commit is contained in:
nemunaire 2018-10-16 11:46:09 +02:00
parent fd1a397c14
commit e68cdc1108
1 changed files with 7 additions and 0 deletions

View File

@ -72,6 +72,7 @@ def check(msg, GNUPG_DIRECTORY, accept_public_key=True, beta=False):
from archive import _guess_mime
# Looking for signed content
lpart = None
for part in msg.walk():
payload = part.get_payload()
if payload is not None and not part.is_multipart() and part.get_payload(decode=True).find(b"-----BEGIN PGP SIGNED MESSAGE-----") >= 0:
@ -100,3 +101,9 @@ def check(msg, GNUPG_DIRECTORY, accept_public_key=True, beta=False):
yield MailTest("Public key file discovered, but content-type mismatched: got %s instead of application/pgp-keys." % part.get_content_type(), 2)
yield from import_pubkey(part.get_payload(decode=True), GNUPG_DIRECTORY)
return
elif lpart is not None and part.get_filename() is not None and lpart.get_filename() is not None and part.get_filename()[:len(lpart.get_filename())] == lpart.get_filename():
yield MailTest("Standalone non-armored signature file discovered. Avoid using binary signature over SMTP (see RFC2015 #2. PGP data formats).", 2)
yield (lpart.get_payload(decode=True), part.get_payload(decode=True))
lpart = part