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

3.1k views Asked by At

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!

1

There are 1 answers

1
Todd Liang On

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");