Extract the correct Sender Certificate in As4InboundHandler #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.