ced236
9 years agoNew Contributor
Digest value obtained programmatically different from soapUI?
Hello,
I would like to sign a xml document to send it to a soap web service. To begin, I am trying to sign a simple node like this:
<test xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-F4821D01E882FF4507149477187940483"> truc </test>
The digest value of the test element is “pdB9Sx1CJ6Cj2z/FoqamVKkjxZ8= ».
Here is a simple python code to compute the digest value:
from xml.dom import minidomfrom xml.dom.ext import c14nimport base64import hashlib doc = minidom.parse('file2.xml')canonical_xml = c14n.Canonicalize(doc) print (canonical_xml) print base64.b64encode(hashlib.sha1(canonical_xml).digest()) print (" ".join("{:02x}".format(ord(c)) for c in canonical_xml))
The node «test« is in the file named ‘file2.xml’.
To test the soap request, I create it with SoapUI but the digest value of this node is different. I don’t understand why the digest value from SOAPUI is different. I have «ONNdniHbKnsMddcMR8rUuPWxbgw= ».
Here is a part from the document xml generated by SoapUI:
<ds:Reference URI="#id-F4821D01E882FF4507149477187940483"> <ds:Transforms> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <ec:InclusiveNamespaces PrefixList="soapenv urn" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/> </ds:Transform> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> <ds:DigestValue>ONNdniHbKnsMddcMR8rUuPWxbgw=</ds:DigestValue> </ds:Reference>
Can someone explain to me why those digest values are different?