XML Canonicalization algorithm gives two difference results when called directly than when called as part of an xml digital signature?

落花浮王杯 提交于 2019-11-30 19:39:57

The way in which XML Sig handles whitespace is, in my opinion broken. It's certainly not compliant with what most right-thinking people would call canonicalization. Changing whitespace should not affect the digest, but in xmlsig, it does.

One possible workaround is to pass the document through a canonicalizer routine before passing it to the signature generation code. That should make things far more predictable.

This article might help clarify things.

It looks like in your second piece of code you have

xmlDoc.PreserveWhitespace = true;

while in the first you do not.

As I understand it, the canonicalisation specification asks to preserve the whitespace between elements, so I suggest you include this line in both.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!