Question

Because of specifications imposed on me I have written my own C# code to sign XML, and to validate signed XML. Much like the SignedXml class does, but this way I'm more flexible e.g. in using XML namespace prefixes or not (it seems SignedXml does NOT like namespace prefixes in the signature XML, but my XML specs say I must have them), and in the algorithm for the signature (specs now say sha256).

Everything seems to work, but an "imperfection" that bothers me is that - for example - when validating the xml, I need to transform or verify data using a particular class of object, and all I have to go by is the algorithm URI specified in the XML. An example would be canonicalization: if the XML says "http://www.w3.org/2001/10/xml-exc-c14n#" I know I can use the XmlDsigExcC14NTransform class, but my question is: is there a way to get from such a URI (or any URI) to a particular class of object?

I now use a list of URI's known to me and the object classes (I think) they refer to (or compare it to the Algorithm property of a list of known object classes, e.g. XmlDsigExcC14NTransform.Algorithm), which is not really what I like.

Was it helpful?

Solution

This is not well documented but System.Security.Cryptography.CryptoConfig.CreateFromName(string) will return you the transform associated with an URI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top