abhishek-ram / pyas2-lib

AS2 Library for building and parsing Messages and MDNs
GNU General Public License v3.0
42 stars 27 forks source link

Lack of Content-Transfer-Encoding of a binary message causing signature validation failure #47

Closed daviialvesjr closed 2 years ago

daviialvesjr commented 2 years ago

We are receiving a message from IBM Starling. The message is encrypted, signed and compressed. The symptom is that the self.digest_alg = verify_message(mic_content, signature, verify_cert) function fails. We realised that the canonicalize is not treating the message as binary as it should because of the lack of the Content-Transfer-Encoding property. Inside canonicalize the email_message has the following header: Content-Type: application/pkcs7-mime; smime-type=compressed-data; name=smime.p7m By forcing the message as binary everything works well, however it will probably break other messages. What is the best way to deal with this case?

abhishek-ram commented 2 years ago

Well we cannot always assume that it is binary as the message could also be base64 encoded. There are a few options:

Let me know your thoughts @daviialvesjr
cc @chadgates

chadgates commented 2 years ago

I'd suggest to extend Partner class with canonicalize_as_binary option and make it configurable in django-pyas2 on a partner level as well.

daviialvesjr commented 2 years ago

All right, I'll do it as suggested by @chadgates. Thanks!!