Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No MDN found in the received message #13

Closed
activeyossi opened this issue Jun 18, 2019 · 9 comments
Closed

No MDN found in the received message #13

activeyossi opened this issue Jun 18, 2019 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@activeyossi
Copy link

HI,
Trying to configure an Amazon Vendor Central connection and keep getting "No MDN found in the received message" when receiving a test message from Amazon.

Sending a test file to them works fine, and we are also receiving back an MDN from them.
However, when we send, we keep getting the error, and when we downloaded the received messege, it decripted properly and looks fine.

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pyas2/views.py", line 90, in post
status, detailed_status = as2mdn.parse(request_body, self.find_message)
File "/usr/lib/python3.6/site-packages/pyas2lib/as2.py", line 774, in parse
self.orig_message_id, orig_recipient = self.detect_mdn()
File "/usr/lib/python3.6/site-packages/pyas2lib/as2.py", line 856, in detect_mdn
raise MDNNotFound('No MDN found in the received message')
pyas2lib.exceptions.MDNNotFound: No MDN found in the received message

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pyas2lib/as2.py", line 559, in parse
mic_content, signature, verify_cert)
File "/usr/lib/python3.6/site-packages/pyas2lib/cms.py", line 360, in verify_message
for attr in signed_attributes.native:
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4243, in native
raise e
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4239, in native
self._native = [child.native for child in self]
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4239, in <listcomp>
self._native = [child.native for child in self]
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 3777, in native
raise e
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 3773, in native
self._native[name] = child.native
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4243, in native
raise e
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4239, in native
self._native = [child.native for child in self]
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 4239, in <listcomp>
self._native = [child.native for child in self]
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 870, in native
self.parse()
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 935, in parse
raise e
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 919, in parse
spec_params=passed_params
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 5242, in _parse_build
return (_build(*info, spec=spec, spec_params=spec_params), new_pointer)
File "/usr/lib/python3.6/site-packages/asn1crypto/core.py", line 5178, in _build
tag
ValueError: Unknown element - context class, constructed method, tag 0
while parsing asn1crypto.core.Any
while parsing asn1crypto.cms.SetOfAny
while parsing asn1crypto.cms.CMSAttribute
while parsing asn1crypto.cms.CMSAttributes
@abhishek-ram
Copy link
Owner

This is very strange, can you generate debug logs and attach it in this ticket.

@activeyossi
Copy link
Author

activeyossi commented Jun 18, 2019

Hi abhishek,

Thanks for the quick response.
Forgive me if this is not what you are looking for, I'm not familiar with Python/Dejengo
I followed a StackOverflow and enabled logging and this is what i got:

b'content-length: 3303\ncontent-type: application/pkcs7-mime; name="smime.p7m"; 
smime-type=enveloped-data\ndate: 18 Jun 2019 15:08:16 GMT\nfrom: as2@XXX.1.XX.56\nmessage-id: <0abed517-ade1-489a-b273-603edaa3364d>\nsubject: AS2 Message\nas2-version: 1.1\nas2-from: XXXXXXX\na$
Check to see if payload is an Asynchronous MDN.
Payload is not an MDN parse it as an AS2 Message
Received an AS2 message with id <0abed517-ade1-489a-b273-603edaa3364d> for organization XXXXX from partner XXXXX.

The log doesn't seem to mention the error but we received the same traceback.
AmazonTest file was received and decoded correctly. I just opened it with notepad and its a full EDI message. And AS2 sent back to Amazon:

--===============7118937947823148819==
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

The AS2 message could not be processed. The disposition-notification report has additional details.

--===============7118937947823148819==
Content-Type: message/disposition-notification
Content-Transfer-Encoding: 7bit

Reporting-UA: pyAS2 Open Source AS2 Software
Original-Recipient: rfc822; XXXXX
Final-Recipient: rfc822; XXXXX
Original-Message-ID: <03a633f5-d6c2-407b-975f-4fa0a53c82d1>
Disposition: automatic-action/MDN-sent-automatically; processed/Error: unexpected-processing-error

I am kinda new to EDI, but when receiving a message, we need to send back the MDN, right?

@abhishek-ram
Copy link
Owner

Okay I see that you have enabled logging, I will need the log file to debug this further.
Yes on receiving a message we need to send back an MDN.

@activeyossi
Copy link
Author

log attached

One thing I want to mention, but im not sure it is related, is that Amazon is providing us with a .crt public certificate and when trying to upload it in pyas2, we get an error:
Unsupported certificate format, supported formats include .pem, .der, .cer.

I researched online a little bit, and it seems that they provide us with a PEM type file because it has -----BEGIN CERTIFICATE----- in the top.
So all I needed to do is change the extension.

However, when trying to load the certificate to pyas2, we get the error unable to get local issuer certificate, so I saved it without validation.
pyas2.log

@abhishek-ram
Copy link
Owner

Okay the .crt is also a valid extension, I will update it.
The error you got is because of certificate validation and yes we need to save amazon certs without validation.

You have logged only django-pyas2 messages, I need the logs of pya2lib as well. Here is the necessary logging configuration

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'console': {
            'format': '%(name)-12s %(levelname)-8s %(message)s'
        },
        'file': {
            'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
        }
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'console'
        },
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'formatter': 'file',
            'filename': './pyas2-debug.log'
        }
    },
    'loggers': {
        'django-pyas2': {
            'level': 'DEBUG',
            'handlers': ['console', 'file']
        },
        'pyas2lib': {
            'level': 'DEBUG',
            'handlers': ['console', 'file']
        }
    }
}

@activeyossi
Copy link
Author

Got it, a lot more details now.

pyas2-debug.log

@abhishek-ram
Copy link
Owner

@activeyossi there are a couple of issues here. I was able to fix the first but the second issue which is failures in signature verification for MDNs was caused by some of the changes we did. I am now working on how we can address this issue.

@abhishek-ram
Copy link
Owner

@activeyossi I have released a newer version with fixes. Can you please upgrade and try again.

@abhishek-ram abhishek-ram self-assigned this Jun 25, 2019
@abhishek-ram abhishek-ram added the bug Something isn't working label Jun 25, 2019
@activeyossi
Copy link
Author

Working like a charm! Thank you man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants