Search code examples
msxmlxml-signaturecanonicalizationmsxml6c14n

MSXML and cannonical XML


Is there a good way to canonicalize XML with MSXML6?

I have an XML document that I load into a IXMLDOMDocument object. I need to perform an operation like singing or hashing on the document. I would like to put it into XML canonical form a la C14N or similar standard. IXMLDOMDocument has a save to file method, but I don't think that canonicalizes it first nor does it really provide any knobs to control how it writes the file. There is the MXXMLWriter60 that lets you control some stuff like indention, encoding format, etc., but it doesn't seem like it has everything to do the complete the C14N standard. The .net framework has XmlDsigC14NTransform which seems idea, but obviously not usable from where I am in the stack. It seems like MSXML does have some support for XMLDSIG so that code should canonicalize stuff, but it doesn't expose any of that.

Any suggestions?


Solution

  • The short answer is no, MSXML 6.0 doesn't have a cannonicalizer you can use. If old versions of MSXML with canoncalizers existed, they are not included in modern Windows.

    Windows does ship inbox components that can canonicalize XML per the c14n standard and many others; however, they are not exposed by any public APIs.

    Hope this helps!