aspose file tools*
The moose likes Web Services and the fly likes Canonicalize and sign xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Canonicalize and sign xml" Watch "Canonicalize and sign xml" New topic
Author

Canonicalize and sign xml

Igor Delac
Greenhorn

Joined: Nov 23, 2012
Posts: 6
Should those two xml docs. have same signature?

and

I noticed that if I sign them, digest and signature values are different in both cases. Any idea how to transform it to have same signature?
Here's code I use:
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 468
    
    2
I noticed that if I sign them, digest and signature values are different in both cases. Any idea how to transform it to have same signature?

Maybe one should ask the question in the other direction. Why would you think that would give the same signature? They are "different" in the sense of being an octet stream even after the canonicalization should be the first intuition and that is the correct conclusion, though.

Any idea how to transform it to have same signature?

You sure can transform them to some common output. But that is heavily dependent of detail setting of the formatter and the error prong white-space treatment... For that reason, maybe you should both apply a transformation so that they share the common defaut behaviour in the formatting and white-space treatment.

For instance, the first xml you reverse the positions under items with an template like this.

whereas, you apply a similar template on the second.

That is the basic idea.

Signature is a technology rigorous to the detail. You need to ask why such kind of mixed up turns up at all from the source.
Igor Delac
Greenhorn

Joined: Nov 23, 2012
Posts: 6
Thank you for explanation. It make sense. Also your suggestion to arrange items in xml is also very useful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Canonicalize and sign xml
 
Similar Threads
Digital Signature Validation
Signing & Verify XML Document
How to use SAML 2.0 Sender Vouches?
Reference URI error creating digital signature for a specific XML element/ Node
NUll pointer exception in XML sig program