Try to handle binary signature
This commit is contained in:
parent
fd1a397c14
commit
e68cdc1108
@ -72,6 +72,7 @@ def check(msg, GNUPG_DIRECTORY, accept_public_key=True, beta=False):
|
|||||||
from archive import _guess_mime
|
from archive import _guess_mime
|
||||||
|
|
||||||
# Looking for signed content
|
# Looking for signed content
|
||||||
|
lpart = None
|
||||||
for part in msg.walk():
|
for part in msg.walk():
|
||||||
payload = part.get_payload()
|
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:
|
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 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)
|
yield from import_pubkey(part.get_payload(decode=True), GNUPG_DIRECTORY)
|
||||||
return
|
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
|
||||||
|
Reference in New Issue
Block a user