4
我需要使用XAdES模板簽署xml。我使用2個參考。第二個問題是,如果我添加變換,它將正常工作(signedXml.CheckSignature()返回True),沒有這個變換它將返回False。C#使用XAdES簽名XML文檔
我的代碼:
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));
簽名的第二部分。
<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>
是.NET中的問題嗎?
謝謝。