EDN Admin
Well-known member
I am implementing a XAdES signing solution on top of System.Security.Xml.SignedXml class. Because XAdES adds some objects appended at the end of the signature and those elements must be included on it, I inherit SignedXml to make possible reference those
objects with the System.Security.Xml.Reference class.<br/>
<br/>
The implemented solution generates a XML file that seems to be valid, but references to <Object> nodes in the signature are misscalculated and makes the signature invalid. In fact, when signing the <KeyInfo> node it generates an invalid SHA1 hash
and the validator reports that the key included in the XML is invalid.<br/>
<br/>
The SignedXML inherited class is:<br/>
<br/>
<div style="color:black; background-color:white
<pre><span style="color:blue public <span style="color:blue class CustomIdSignedXml : SignedXml
{
<span style="color:blue public CustomIdSignedXml(XmlDocument doc)
: <span style="color:blue base(doc)
{
<span style="color:blue return;
}
<span style="color:blue public <span style="color:blue override XmlElement GetIdElement(XmlDocument doc, <span style="color:blue string id)
{
<span style="color:blue if (id.Equals(<span style="color:blue this.KeyInfo.Id) == <span style="color:blue false)
{
<span style="color:blue return <span style="color:blue base.GetIdElement(doc, id);
}
<span style="color:blue else
{
<span style="color:blue return <span style="color:blue this.KeyInfo.GetXml();
}
}
[/code]
<br/>
By the way, using XAdESnet project (http://xadesnet.codeplex.com/) I get the same behaviours. The XAdESnet project generates a XML file wich is only validable by itself not other tools.
View the full article
objects with the System.Security.Xml.Reference class.<br/>
<br/>
The implemented solution generates a XML file that seems to be valid, but references to <Object> nodes in the signature are misscalculated and makes the signature invalid. In fact, when signing the <KeyInfo> node it generates an invalid SHA1 hash
and the validator reports that the key included in the XML is invalid.<br/>
<br/>
The SignedXML inherited class is:<br/>
<br/>
<div style="color:black; background-color:white
<pre><span style="color:blue public <span style="color:blue class CustomIdSignedXml : SignedXml
{
<span style="color:blue public CustomIdSignedXml(XmlDocument doc)
: <span style="color:blue base(doc)
{
<span style="color:blue return;
}
<span style="color:blue public <span style="color:blue override XmlElement GetIdElement(XmlDocument doc, <span style="color:blue string id)
{
<span style="color:blue if (id.Equals(<span style="color:blue this.KeyInfo.Id) == <span style="color:blue false)
{
<span style="color:blue return <span style="color:blue base.GetIdElement(doc, id);
}
<span style="color:blue else
{
<span style="color:blue return <span style="color:blue this.KeyInfo.GetXml();
}
}
[/code]
<br/>
By the way, using XAdESnet project (http://xadesnet.codeplex.com/) I get the same behaviours. The XAdESnet project generates a XML file wich is only validable by itself not other tools.
View the full article