I need to sign xml with an XAdES template. I use 2 links. The problem is the second, if I add Transform, it will work fine (signedXml.CheckSignature () returns True), without this conversion it will return False.
my code is:
System.Security.Cryptography.Xml.Reference reference2; System.Security.Cryptography.Xml.SignedXml signedXml; ... reference2 = new Reference(); reference2.Type = "http://uri.etsi.org/01903/v1.1.1#SignedProperties"; reference2.Uri = "#SignedPropertiesId"; //reference2.AddTransform(new XmlDsigExcC14NTransform()); IF I COMMENT THIS LINE IT WONT WORK signedXml.AddReference(reference2); signedXml.ComputeSignature(); XmlElement xmlDigitalSignature = signedXml.GetXml(); xmlDoc.DocumentElement.AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true)); signedXml.CheckSignature(); //return false if dont use Transform in second REF signedXml.ComputeSignature(); XmlElement xmlDigitalSignature = signedXml.GetXml(); xmlDoc.DocumentElement.AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true));
second part of the signature.
<ds:KeyInfo> <ds:X509Data> <ds:X509Certificate>cert...</ds:X509Certificate> </ds:X509Data> </ds:KeyInfo> <ds:Object> <xds:QualifyingProperties Target="#SignatureId"> <xds:SignedProperties Id="SignedPropertiesId"> <xds:SignedSignatureProperties>
Is this a problem in .NET?
Thanks.
source share