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

Extract the correct Sender Certificate in As4InboundHandler #28

Closed

Conversation

tjeb
Copy link

@tjeb tjeb commented Sep 20, 2019

Having an application that uses the sender certificate for additional checks and logging, we noticed a problem with the AS4 Implementation; in some cases, the 'senderCertificate' was in fact the receiver's certificate. I have not checked whether this affects the mdn or receipt, but it seems to be quite a potential interoperability issue.

With the original XPath, the first certificate encountered in the request was extracted as the sender certificate. However, the first certificate can be the receiver's certificate as well, in case encryption is used.

With this change, locating the sender's certificate is a two-step process: first find the identifier referenced in the signature, then find the certificate with that identifier in the document.

I suspect it can be improved upon still, but for the case we encountered, this patch appears to fix the issue.

With the original XPath, the first certificate encountered in the request was extracted as the sender certificate. However, the first certificate can be the receiver's certificate as well, in case encryption is used.

With this change, locating the sender's certificate is a two-step process: first find the identifier referenced in the signature, then find the certificate with that identifier in the document.
@ekorra ekorra requested a review from FrodeBjerkholt October 14, 2019 07:22
Copy link
Contributor

@evenos evenos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we need to get in. In the case where the sender provides the certificate thewy used to encrypt alongside there own certificate used to sign messgaes the encryption certificate would normally end up first in the document and be wrongly reported.

The approach provided here is good.

Could be combined in one query
//wsse:BinarySecurityToken[@wsu:Id=substring-after(//xmldsig:Signature/xmldsig:KeyInfo/wsse:SecurityTokenReference/wsse:Reference/@URI, '#')]

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

Successfully merging this pull request may close these issues.

2 participants