Thursday, November 11, 2010

How to sign JAR files

Since JAR files need to be downloaded as part of a Java applet you should digitally sign them. Before we can start make sure you have Java SDK keytool and jarsigner in your path. You can find these tools in Java SDK bin directory.

Create a new key,
  • keytool -genkey -keystore myKeystore -alias myself

When asked, fill the information regarding the new key name, password, etc. This procedure creates myKeystore on you disk.

Create a self signed certificate,
  • keytool -selfcert -alias myself -keystore myKeystore

List the contents of the keystore (not mandatory),
  • keytool -list -keystore myKeystore

        Keystore type: jks
        Keystore provider: SUN

        Your keystore contains 1 entry:
        myself, Fri Nov 12 19:29:32 PST 2010, keyEntry,
        Certificate fingerprint (MD5):
        C2:E9:BF:F9:D3:DF:4C:8F:3C:5F:22:9E:AF:0B:42:9D

Repeat these last step to sign all your JAR files,
  • jarsigner -keystore myKeystore test.jar myself

1 comment:

  1. Thanks for posting the whole procedure to sign JAR files. You have nicely explained each step. I will try to implement the same by following this article.
    e signatures

    ReplyDelete