问题
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.
回答1:
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();
}
来源:https://stackoverflow.com/questions/24915753/java-program-to-verify-digital-signature-signed-by-signtool