• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Digital signing XML message using Java

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have an unsupported application at my place of work which digitally signs XML messages using a certificate from a keystore that we want to replace. Im attempting to write a replacement application using Java however when I sign the XML, the generated digital signatures between both the existing application and my Java code are different. As the existing application obviously works Im not sure what is wrong with my Java code.

The digital signatures generated between both the existing application and my Java code are exactly the same except from the digest value and the signature value.

Here is the digital signature that is generated:



Here is the code that I use to generate the digital signature:



Can someone more experienced than me please take a look over my code to ensure that it looks OK and im not missing anything obvious? Also, any other troubleshooting tips that can be offered would be greatly appreciated. Thanks
 
John Paul Hoey
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a quick update to inform anyone who may be interested that I managed to get my code to work. There where two issues:

1) The reference transforms were being added to the arraylist in the incorrect order, the ordering has to be the other way around as follows:



2) The white space between the elements of the XML that was being loaded by my code had to be removed. I did this using the following code:



Once I had performed the above, the digital signatures included within my XML worked as expected.

Just to add, I used the following code to also verify my digital signatures worked:



Hopefully the above may help someone in the future.
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic