lunedì 26 dicembre 2016

Use the Java Keystore to sign a Windows Executable file

If you have already a valid Java Keystore released by a certification authority (CA), you can use it to sign a Windows Executable file (for example a setup).

You need a Java Runtime and a Windows SDK:

set JAVA_HOME=c:\Programs Files\Java\jdk8
set WIN_SDK=C:\Program Files (x86)\Windows Kits\10

Convert the Java Keystore to the Personal Information Exchange (PFX) format:
%JAVA_HOME%\bin\keytool -importkeystore -srckeystore keystore.jks
 -destkeystore keystore.pfx -deststoretype PKCS12
Sign the executable file
%WIN_SDK%\bin\x64\signtool.exe sign /v /f keystore.pfx 
 /t http://timestamp.verisign.com/scripts/timstamp.dll 
 /p mypassword mysetup.exe
To verify your file
%WIN_SDK%\bin\x64\signtool.exe verify /pa mysetup.exe