0

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?

sam msft
  • 537
  • 6
  • 17
  • As far as I can tell XMLDSIG was implemented in MSXML 5.0 for MS Office but not in MSXML 3.0, 4.0, or 6.0. So welcome to my world: Microsoft implements things in .Net or in Office instead of at the platform level, leaving huge numbers of developers to their own devices. I guess that what happens when groups are allowed to burn company resources on their own private little worlds. The shareholders should be livid, the users sure are. – Bob77 Oct 28 '16 at 05:02
  • I am not sure what you mean. You can code against the MSXML3/6 library at the platform level on any SKU of Windows, even Mobile, IoT core, desktop, etc. if you are writing native code. It is just COM after all. The DLLs are in system32 FWIW. – sam msft Nov 05 '16 at 22:33
  • Anyway, it doesn't looks like there is a good API in MSXML to canonicalize. Obviously it can and does canonicalize as part of XMLDISG, but it is not exposed. Hypothetically if one had source code access to the underlying disig object, it would not hard to have it expose a new interface that exposes the private canonicalize methods. – sam msft Nov 05 '16 at 22:38

1 Answers1

0

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!

sam msft
  • 537
  • 6
  • 17
  • A [cannon](https://en.wiktionary.org/wiki/cannon#Noun) has nothing to do with a [canon](https://en.wiktionary.org/wiki/canon#Noun) - the former is mostly known for damage, the latter mostly through singing. – AmigoJack Nov 02 '22 at 04:24