XML Signature: How to calculate the digest value?

前端 未结 4 1351
执念已碎
执念已碎 2020-12-23 21:44

I have an XML like this



  
    A
  
  

        
4条回答
  •  眼角桃花
    2020-12-23 22:15

    I have encountered exactly this problem myself: I was generating an XML signature in Java & validating in .NET, and the validation always failed. In my case the cause was the 'print XML to file' function XMLWrite.m (yes, in MATLAB*) which was 'pretty printing' the XML, inserting tabs, spaces, and newlines as it saw fit. Since these are part of the document, naturally the validation failed (it failed in Java, too). Looking at your source, this may be happening to you. Use a Transformer (javax.xml.transform.*) to serialise your DOM properly without changing the content.

    *You did know that MATLAB understands Java as well? You can just type Java statements into the interpreter console & they will be executed like native m-code.

提交回复
热议问题