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

File getting corrupted with encrypt or sign true on Mac, Amazon Linux (maybe others too). #49

Closed robincsamuel closed 2 years ago

robincsamuel commented 2 years ago

I tested the library on an ubuntu machine and everything worked well. But, then I tested the same on a mac and I got a corrupted file. The file size too was different. However, it works fine if I turn off the sign & encrypt options, or use content type binary. I've faced the same issue when I tested the same on an EC2 with Amazon Linux.

I've compared the binaries and t looks like the bytes are changing when decrypted.

And .txt or .csv works in either case. The issue is when a more complex file is transferred, like a png image or an xlsx file.

PS: I noticed #47 and it looks similar.

abhishek-ram commented 2 years ago

I have a mac and I have run it successfully there (same with EC2), please run django-pyas2 on both ends and let me know if the issue persists.

robincsamuel commented 2 years ago

@abhishek-ram Yeah, I used django-pyas2 on both ends (I have set up two instances of ubuntu & Amazon Linux to test the same). The ubuntu version works fine, I tested that with a few other as2 gateways as well. But the Amazon Linux version and two of my MacBooks have the issue. It works if I exclusively set the content type to binary.

I can share access to these servers if you'd like to test it out.

abhishek-ram commented 2 years ago

well, for binary files you are expected to set the content type to binary as we cannot detect it automatically

robincsamuel commented 2 years ago

Ah okay. I'm still wondering how it's working on an ubuntu server and not on others.

Also, it works when using any other client to send. For example, I earlier used the windows client, Mendelson as2, to send files to django-pyas2 (on ubuntu) and it worked fine. The content-type was always the default, application/edi-consent.

Please correct me if I'm wrong, the user who sends the file isn't explicitly selecting binary, it's set to application/edi-consent, so I'm a bit confused on what basis they'd decide if the content type should be set to binary or not? I mean, they are just uploading the file and sending it. It's base64 for .txt but binary for an image or an excel document.

PS: I'm new to AS2 protocol, and am still exploring. Please excuse :)