2

I have digitally signed a file(either .exe or .dll not a jar file) using SignTool. Signtool can also verify the digital signature. But my requirement is to check digital signature of file signed by signtool using java program.

I searched on internet but didn't find any info. Could you please give me pointers regarding the same?

Thanks for your suggestion.

JLyon
  • 297
  • 1
  • 4
  • 19
  • possible duplicate of [How to verify a jar signed with jarsigner programmatically](http://stackoverflow.com/questions/1374170/how-to-verify-a-jar-signed-with-jarsigner-programmatically) – Dmitry Ginzburg Jul 23 '14 at 16:25
  • Thanks Dmitry. My file here is an exe or dll file which was already signed using SignTool. Its not a jar file. I need to verify signature using java program – JLyon Jul 23 '14 at 16:32

1 Answers1

0

Signing Code

jarsigner -keystore c:/my.keystore -storepass ozziepassword e:/securityApplet.jar ozzie

Verify Code:

jarsigner -verify e:/securityApplet.jar


To verify signature:

   Signature signer = null;
    try {
        signer = Signature.getInstance("SHA1withRSA");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return "Verify : No Such Algorith Exception." + e.getMessage();
    }
    try {
        result = signer.verify(digitalSignature);
    } catch (SignatureException e) {
        e.printStackTrace();
        return "Verify : Signature Exception." + e.getMessage();

    }
bNd
  • 7,512
  • 7
  • 39
  • 72
  • Thanks TBM. My file here is an exe or dll file which was already signed using SignTool. Its not a jar file. I need to verify signature using java program – JLyon Jul 23 '14 at 16:33
  • @jitendrabhati no idea about .exe and dll file. as I have used applet. I edit my post. it may help you. – bNd Jul 23 '14 at 16:40
  • Thanks TBM. What is digitalSignature in below code statement: result = signer.verify(digitalSignature); Pls share that code snippet as well. – JLyon Jul 23 '14 at 16:48
  • refer it http://docs.oracle.com/javase/7/docs/api/java/security/Signature.html#verify(byte[]) – bNd Jul 23 '14 at 17:00