Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is it possible to use http://www.w3.org/2006/12/xml-c14n11 CanonicalizationMethod with SignedXml?

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

is throwing

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

Thank You!

like image 872
shkipper Avatar asked Nov 28 '14 12:11

shkipper


1 Answers

Doesn't look like it has been implemented by .NET yet.

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

You may have to make your own Transform class like this:

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();
        }
    }

And map your transform to "http://www.w3.org/2006/12/xml-c14n11".

CryptoConfig.AddAlgorithm(typeof(XmlDsigC14N11Transform), "http://www.w3.org/2006/12/xml-c14n11");
like image 143
Todd Liang Avatar answered Sep 18 '22 11:09

Todd Liang