0
我遇到了XmlDsigC14NTransform問題。我試圖從 http://www.di-mgt.com.au/xmldsig2.html(部分撰寫規範化的SignedInfo元素並計算它的SignatureValue) 重複例子,但我的代碼從xml中失去空格,我不能得到正確的hexdump。C#爲什麼XmlDsigC14NTransform從xml中刪除所有空格
我的C#代碼:
XmlDocument signedInfoXml = new XmlDocument();
signedInfoXml.Load(@"C:\temp\new_sign.txt");
XmlDsigC14NTransform xmlTransform = new XmlDsigC14NTransform();
xmlTransform.LoadInput(signedInfoXml);
MemoryStream memoryStream = (MemoryStream)xmlTransform.GetOutput();
return BitConverter.ToString(memoryStream.ToArray()).Replace("-"," ");
源XML(從文件C:\ TEMP \ new_sign.txt):
<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>UWuYTYug10J1k5hKfonxthgrAR8=</DigestValue>
</Reference>
</SignedInfo>
我怎麼能保存到空格我的XML,並得到規範化XML像在樣品中(http://www.di-mgt.com.au/xmldsig2.html)?
保留空格是不一樣的規範化,儘管它可能工作在非常有限的情況下。 – UserControl