Reputation: 1413
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!
Upvotes: 8
Views: 3728
Reputation: 21
The issue is a bit old but I stumbled upon it these days and found the first answer very useful, although to make it work I had to add the namespace of the canonicalization algorithm to the static property SignedXml.KnownCanonicalizationMethods
. It's a private property of the standard class, but with a bit of trickery you can add the namespace to the collection anyway like this:
var KnownCanonicalizationMethodsProperty = typeof(SignedXml).GetProperty("KnownCanonicalizationMethods", BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Static);
(KnownCanonicalizationMethodsProperty.GetValue(null) as List<string>).Add("http://www.w3.org/2006/12/xml-c14n11");
Upvotes: 0
Reputation: 115
Doesn't look like it has been implemented by .NET yet.
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");
Upvotes: 6