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

The Message Integrity Code (MIC) does not match the sent AS2 message #40

Open
Jaimies opened this issue Nov 19, 2022 · 0 comments
Open

Comments

@Jaimies
Copy link

Jaimies commented Nov 19, 2022

Overview

When sending a message with an attachment, the following error occurs:

The Message Integrity Code (MIC) does not match the sent AS2 message (required: **required_mic**, sha256, returned: **returned_mic**, sha256) {"message_id":"**message_id**"}

Meanwhile, sending a message without an attachment does not produce an error.

Steps to reproduce

This issue can be reproduced with the example, included in the library. To do that, run the following commands:

git clone https://github.com/tiamo/phpas2.git phpas2_issue_reproduction
cd phpas2_issue_reproduction/example
composer install
chmod +x ./bin/console
# run the server in the background with no output
php -S 127.0.0.1:8000 ./public/index.php >& /dev/null &
echo "This is the message" > example_message.txt
php bin/console send-message --from mycompanyAS2 --to phpas2 --file example_message.txt

The last command produces the following output:

[2022-11-19 17:34:33] app.DEBUG: Build the AS2 message to send to the partner
[2022-11-19 17:34:33] app.DEBUG: Signing the message using partner key
[2022-11-19 17:34:33] app.DEBUG: Calculate MIC {"mic":"**mic**, sha256"}
[2022-11-19 17:34:33] app.DEBUG: Compressing outbound message after signing...
[2022-11-19 17:34:33] app.DEBUG: Encrypting the message using partner public key
[2022-11-19 17:34:33] app.DEBUG: AS2 message has been built successfully
[2022-11-19 17:34:33] app.DEBUG: AS2 message successfully sent to partner
[2022-11-19 17:34:33] app.DEBUG: Synchronous MDN received from partner
[2022-11-19 17:34:33] app.DEBUG: Found MDN report for message ["**message_id**"]
[2022-11-19 17:34:33] app.DEBUG: Message has been successfully processed, verifying the MIC if present.
[2022-11-19 17:34:33] app.ERROR: The Message Integrity Code (MIC) does not match the sent AS2 message (required: **required_mic**, sha256, returned: **returned_mic**, sha256) {"message_id":"**message_id**"}

However, if one were to run bin/console send-message --from mycompanyAS2 --to phpas2 (sending a message without an attachment) instead of the last command, the message would be sent successfully:

[2022-11-19 17:42:47] app.DEBUG: Build the AS2 message to send to the partner
[2022-11-19 17:42:47] app.DEBUG: Signing the message using partner key
[2022-11-19 17:42:47] app.DEBUG: Calculate MIC {"mic":"**mic**, sha256"} []
[2022-11-19 17:42:47] app.DEBUG: Compressing outbound message after signing...
[2022-11-19 17:42:47] app.DEBUG: Encrypting the message using partner public key
[2022-11-19 17:42:47] app.DEBUG: AS2 message has been built successfully
[2022-11-19 17:42:47] app.DEBUG: AS2 message successfully sent to partner
[2022-11-19 17:42:47] app.DEBUG: Synchronous MDN received from partner
[2022-11-19 17:42:47] app.DEBUG: Found MDN report for message ["**message_id**"]
[2022-11-19 17:42:47] app.DEBUG: Message has been successfully processed, verifying the MIC if present.
[2022-11-19 17:42:47] app.DEBUG: File Transferred successfully to the partner

System information

OS: Ubuntu 20.04.5 LTS
PHP: PHP 8.1.12 (cli) (built: Oct 28 2022 17:39:37) (NTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant