Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Xml Signature - problems with enveloped Signatures on Multiple XmlNodes with the same name but different Ids

$
0
0

Read Readers,

I would be grateful for some assistance.

I am signing enveloped Xml Signatures for XmlNodes (cast to XmlElement) where the XmlNodes have the same name.

Each node (of the same name) has a unique Id as per W3C recommendation.

I can successfully sign and validate XmlNodes (with and without ChildNodes) using enveloped methods for multiple XnlNodes of the same name if I place the resultant signature in the root of the document.

However if I add the Signature node into the XmlNode I have signed I run into problems.If for example I have three nodes:

<SubMessage Id="SubMessage0"><..><Signature Id="SubMessage0"><..></Signature></SubMessage>
<SubMessage Id="SubMessage1"><..><Signature Id="SubMessage1"><..></Signature></SubMessage>
<SubMessage Id="SubMessage2"><..><Signature Id="SubMessage2"><..></Signature></SubMessage>

I I do the following:

1. Sign SubMessage2 it validates.

2. Sign SubMessage0 it validates BUT not SubMessage2 no longer validates. If I keep a copy of SubMessage2 before I sign SubMessage0 (in a saved document) and then compare it to the SubMessage2 in the document after I sign SubMessage0 it is the same.

As I said previously if I place the signatures in the root instead of in the XmlNode I am trying to sign it works.

For this I conclude that there is a problem with the signedXml.CheckSignature(public key) which only picks up the first Signature for the same name it sees.

What it odd, I have tried this where I pass only the XmlNode with enveloped signature into a validation method and load the  SignedXml signedXml = new SignedXml((XmlElement)xmlNode2Validate); where only one Xml signature is 'in scope' and it still fails.

If some one has some light to shed on this I would be grateful for some help.

Regards Simon (and yes I do like motorcycle racing!)


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>