Random Noise

cat /dev/random >> /dev/dsp

Signing a JAR file with .spc and .pvk file

with 2 comments

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):


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 \

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


Written by Vivek Unune

August 14, 2007 at 2:58 am

Posted in Java

Tagged with , , ,

2 Responses

Subscribe to comments with RSS.

  1. I followed the above mentioned steps but when I try to sign the jar files I got following errors

    Error jarsigner certificate chain not found for ABC Corp. ABC corp must reference a valid KeyStore key entry containing private key and corresponding public key certificate chain.

    Note: We purchased Microsoft Authenticode Digital ID from VeriSign and we got the .spc and .pvk file.

    Please help us to resolve the issue.


    August 17, 2011 at 10:42 am

    • I resolved this issue it is due to wrong alias name


      August 24, 2011 at 5:06 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: