phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

Mendelson Test fails to decrypt test message #118

Closed fsourd closed 3 years ago

fsourd commented 3 years ago

Dear Philip,

I tried to send messages to the Mendelson test server with MainSendToMendelsonTestServer.

The server returns the message that decryption failed. I tried to use master and release tags 4.5.5, 4.6.1 and 4.6.3.

810 [main] INFO com.helger.as2lib.cert.CertificateFactory - Using internal keystore of type PKCS12
1128 [main] INFO com.helger.as2lib.client.AS2Client - Loading AS2 client keystore from file src\test\resources\mendelson\key3.pfx
1596 [main] INFO com.helger.as2lib.processor.sender.AS2SenderModule - Submitting message [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2001 [main] INFO com.helger.as2lib.processor.sender.AS2SenderModule - Connecting to http://testas2.mendelson-e-c.com:8080/as2/HttpReceiver [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2027 [main] INFO com.helger.as2lib.util.AS2ResourceHelper - Converting [Chunked: false] to a repeatable HTTP entity using file C:\Users\fsourd\AppData\Local\Temp\as2-lib-res-12294307771991540198.tmp
2323 [main] INFO com.helger.as2lib.processor.sender.AS2SenderModule - AS2 Message transferred 4144 bytes in 0.299 seconds at 13.548 KBps [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2329 [main] INFO com.helger.as2lib.util.AS2Helper - Start parsing MDN of [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2370 [main] INFO com.helger.as2lib.util.AS2Helper - Successfully verified signature of MDN of message [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2372 [main] INFO com.helger.as2lib.processor.sender.AS2SenderModule - received MDN [automatic-action/MDN-sent-automatically; processed/error: decryption-failed] [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2372 [main] INFO com.helger.as2lib.crypto.LoggingMICMatchingHandler - MIC IS NOT MATCHED; original MIC: JMGLpx8tEC+nK7Eo2xYKYI982fCshGSDHYPE5I6ARqyJYn1TKwiIkkGeAd9GFv3eXCLKv2wk348KVUvKd78vgA==, sha-512 received MIC: null [<fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>]
2378 [main] ERROR com.helger.as2lib.client.AS2Client - Error sending AS2 message
com.helger.as2lib.disposition.AS2DispositionException: automatic-action/mdn-sent-automatically; processed/error: decryption-failed
    at com.helger.as2lib.disposition.DispositionType.validate(DispositionType.java:141)
    at com.helger.as2lib.processor.sender.AS2SenderModule.receiveSyncMDN(AS2SenderModule.java:746)
    at com.helger.as2lib.processor.sender.AS2SenderModule._sendViaHTTP(AS2SenderModule.java:858)
    at com.helger.as2lib.processor.sender.AS2SenderModule.handle(AS2SenderModule.java:925)
    at com.helger.as2lib.client.AS2Client.sendSynchronous(AS2Client.java:435)
    at com.helger.as2lib.supplementary.main.MainSendToMendelsonTestServer.main(MainSendToMendelsonTestServer.java:127)
2381 [main] INFO com.helger.as2lib.supplementary.main.MainSendToMendelsonTestServer - 
OriginalMessageID: <fso-github-phax-as2-lib-20210118-105241+0100-6172@mycompanyAS2_mendelsontestAS2>
MDN MessageID: <mendAS2-1610963561931-412@mendelsontestAS2_mycompanyAS2>
MDN Disposition: automatic-action/MDN-sent-automatically; processed/error: decryption-failed
Error message: automatic-action/mdn-sent-automatically; processed/error: decryption-failed
MDN Text: IOException reading content.
Sending duration: PT1.7167859S

2381 [main] INFO com.helger.as2lib.supplementary.main.MainSendToMendelsonTestServer - Done

The log of Mendelson server shows

[18/01/2021 07:43:39] [github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2] Inbound transmission is a AS2 message [mycompany-mendelsontest], raw message size: 98 Byte.
[18/01/2021 07:43:39] [github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2] Inbound AS2 message is encrypted.
[18/01/2021 07:43:39] [github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2] Generating outbound MDN, setting message id to "github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2".
[18/01/2021 07:43:39] [mendAS2-1610952219799-400@mendelsontestAS2_mycompanyAS2] Outbound MDN has been signed with the algorithm "SHA-512".`[18/01/2021 07:43:39] [mendAS2-1610952219799-400@mendelsontestAS2_mycompanyAS2] Outbound MDN created for AS2 message "github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2", state set to [processed/error: decryption-failed].
[18/01/2021 07:43:39] [github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2] Outbound MDN details: IOException reading content.
[18/01/2021 07:43:39] [mendAS2-1610952219799-400@mendelsontestAS2_mycompanyAS2] Synchronous MDN sent as answer to message github-phax-as2-lib-20210118-073608+0100-8357@mycompanyAS2_mendelsontestAS2.

Do you experience the same problem ?

I also tried to change crypto algorithms without any success.

phax commented 3 years ago

Hi, did you add the public certificate of your Mendelson Server into the keystore of your as2-lib client? And did you add the public certificate of your as2-lib client into the keystore of your Mendelson server? Are you sure, the case sensititivty of the aliases are correct? Best, Philip

fsourd commented 3 years ago

Thank you for your comments. I am using the public certificate provided by Mendelson test server and I call this test server (http://testas2.mendelson-e-c.com:8080/as2/HttpReceiver). The certificate is included in the example of the as2-lib code and I run it as it is. I have check the certificates have not changed recently. Best, Francis

phax commented 3 years ago
fsourd commented 3 years ago

Thank you, it works well now!