balena / python-smime

S/MIME encoder in pure python
Apache License 2.0
18 stars 17 forks source link

Multipart messages #5

Closed tuck1s closed 5 years ago

tuck1s commented 6 years ago

Multipart messages give an error message:

    to_encode = MIMEText(x)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/email/mime/text.py", line 34, in __init__
    _text.encode('us-ascii')
AttributeError: 'list' object has no attribute 'encode'

I think the code currently assumes a single part, that can be converted into text (and base64 encoded so it fits the block cipher). Is there a more sophisticated way to 'flatten' a multipart message ready for encryption? This would help towards supporting Content-Type multipart/signed also.

I think I found how Thunderbird is doing it, but I'm not good at reading Perl: https://dxr.mozilla.org/mozilla-esr45/source/security/nss/cmd/smimetools/smime

I'm happy to try and work on this, but if you have some hints on how to start that would be great.

tuck1s commented 5 years ago

Thank you.