Don't base64 encode encrypted reports, it's not RFC 3156 compliant and some mailclients (e.g. K-9) have issues with that.

This commit is contained in:
s3lph 2022-04-22 06:46:14 +02:00
parent fff1c7aa25
commit 58070a1505
2 changed files with 24 additions and 3 deletions

View file

@ -1,5 +1,18 @@
# MultiSchleuder Changelog
<!-- BEGIN RELEASE v0.1.3 -->
## Version 0.1.3
Bugfix release
### Changes
<!-- BEGIN CHANGES 0.1.3 -->
- RFC 3156 compliance: Don't base64-encode encrypted reports
<!-- END CHANGES 0.1.3 -->
<!-- END RELEASE v0.1.3 -->
<!-- BEGIN RELEASE v0.1.2 -->
## Version 0.1.2

View file

@ -2,6 +2,7 @@
from typing import Dict, List, Optional, Set
import abc
import email.encoders
import email.mime.base
import email.mime.application
import email.mime.multipart
@ -42,6 +43,7 @@ class Message(abc.ABC):
try:
self._mime = self._encrypt_message(content)
except Exception:
logging.exception('Encryption failed; falling back to unencrypted message')
self._mime = email.mime.text.MIMEText(content, _subtype='plain', _charset='utf-8')
# Set all the email headers
self._mime['From'] = self._from
@ -69,15 +71,21 @@ class Message(abc.ABC):
del sessionkey
# Build the MIME message
# First the small "version" part ...
mp1 = email.mime.application.MIMEApplication('Version: 1', _subtype='pgp-encrypted')
mp1 = email.mime.application.MIMEApplication('Version: 1',
_subtype='pgp-encrypted',
_encoder=email.encoders.encode_noop)
mp1['Content-Description'] = 'PGP/MIME version identification'
mp1['Content-Disposition'] = 'attachment'
# ... then the actual encrypted payload ...
mp2 = email.mime.application.MIMEApplication(str(pgp), _subtype='octet-stream', name='encrypted.asc')
mp2 = email.mime.application.MIMEApplication(str(pgp),
_subtype='octet-stream',
_encoder=email.encoders.encode_noop,
name='encrypted.asc')
mp2['Content-Description'] = 'OpenPGP encrypted message'
mp2['Content-Disposition'] = 'inline; filename="message.asc"'
# ... and finally the root multipart container
mp0 = email.mime.multipart.MIMEMultipart(_subtype='encrypted', protocol='application/pgp-encrypted')
mp0 = email.mime.multipart.MIMEMultipart(_subtype='encrypted',
protocol='application/pgp-encrypted')
mp0.attach(mp1)
mp0.attach(mp2)
return mp0