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

shk*_*per 6 c# digital-signature signedxml

是否可以使用带有SignedXml的http://www.w3.org/2006/12/xml-c14n11 CanonicalizationMethod?

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

扔了

System.Security.Cryptography.CryptographicException: Could not create the XML tr
ansformation identified by the URI http://www.w3.org/2006/12/xml-c14n11.
Run Code Online (Sandbox Code Playgroud)

谢谢!

小智 4

看起来.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();
        }
    }
Run Code Online (Sandbox Code Playgroud)

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

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