SignedXml CanonicalizationMethod - http://www.w3.org/2006/12/xml-c14n11

时间:2014-11-28 12:05:06

标签: c# digital-signature signedxml

是否可以将http://www.w3.org/2006/12/xml-c14n11 CanonicalizationMethod与SignedXml一起使用?

SignedXml signedXml = new SignedXml(xmlDoc);
signedXml.SignedInfo.CanonicalizationMethod = "http://www.w3.org/2006/12/xml-c14n11";

投掷

System.Security.Cryptography.CryptographicException: Could not create the XML tr
ansformation identified by the URI http://www.w3.org/2006/12/xml-c14n11.

谢谢!

1 个答案:

答案 0 :(得分:1)

看起来它还没有被.NET实现。

https://msdn.microsoft.com/en-us/library/system.security.cryptography.xml.signedinfo.canonicalizationmethod(v=vs.110).aspx

你可能需要像这样创建自己的Transform类:

public class XmlDsigC14N11Transform: XmlDsigC14NTransform
    {
        public override void LoadInput(object obj)
        {
            //do something here
            base.LoadInput(obj);
        }

        public override object GetOutput()
        {
            //do something here
            return base.GetOutput();
        }
    }

并将您的转换映射到" http://www.w3.org/2006/12/xml-c14n11"。

CryptoConfig.AddAlgorithm(typeof(XmlDsigC14N11Transform), "http://www.w3.org/2006/12/xml-c14n11");