Browse Source

Try to handle binary signature

master
nemunaire 4 years ago
parent
commit
e68cdc1108
  1. 7
      envelope.py

7
envelope.py

@ -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

Loading…
Cancel
Save