0. You must have a .spc(Certificate) file and a .pvk(Key) file
1. Download pvkimprt.exe from here.
And yes don’t forget to install the downloaded exe!!
2. To generate a .pfx file run:
pvkimprt -PFX myspcfile.spc mypvkfile.pvk
type in the password and give a pathname
3. Import this file from Firefox
4. Export the certificate from Firefox to a .p12 file
5. This file can be used with jarsigner
6. We also need to know the alias of the .p12 file, so copy the .p12 file to the Java bin directory and run:
keytool -list -storetype pkcs12 -keystore mycert-p12.p12
7. Enter the password
8. Then you will see output like this:
Keystore type: pkcs12
Keystore provider: SunJSSE
Your keystore contains 1 entry
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx, Aug 13, 2007, keyEntry,
Certificate fingerprint (MD5):
hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh:hh
9. The xxxx-xxx… number is the alias for the key
10. To sign a jar run:
jarsigner -storetype pkcs12 -keystore mycert-p12.p12 myjar.jar \
“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx”
Update 18th April 2008:
You can also sign the jar using pkcs12 or .p12 certificate using this:
jarsigner -keystore mycert.p12 -storepass mystorepass -keypass mykeypass -storetype “pkcs12″ -signedjar myjar-signed.jar myjar.jar “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx”
To verify your signed jar do:
jarsigner -verify -verbose -keystore mycert.p12 -storepass mystorepass -keypass mykeypass -storetype “pkcs12″ myjar-signed.jar