Monday, February 20, 2012

How to sign JAR files

C:\Documents and Settings\thanooj>keytool -genkey -keystore myKeystore -alias myself
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  thanooj kalathuru
What is the name of your organizational unit?
  [Unknown]:  IT
What is the name of your organization?
  [Unknown]:  Keane India
What is the name of your City or Locality?
  [Unknown]:  Bangalore
What is the name of your State or Province?
  [Unknown]:  KA
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=thanooj kalathuru, OU=IT, O=Keane India, L=Bangalore, ST=KA, C=IN correct?

  [no]:  yes

Enter key password for
        (RETURN if same as keystore password):
Re-enter new password:

-----------------------------------
C:\Documents and Settings\thanooj>keytool -selfcert -alias myself -keystore myKeystore
Enter keystore password:
Enter key password for

C:\Documents and Settings\thanooj>keytool -list -keystore myKeystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

myself, Feb 20, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 2F:A9:E8:6F:67:88:9F:A4:C0:03:F1:A9:4D:91:24:A7

---------------------------------------
C:\Documents and Settings\thanooj>jarsigner -keystore myKeystore C:\CoreJava\
SignJarUsingAnt\dist\SayHelloToMe.jar  myself

Enter Passphrase for keystore:
Enter key password for myself:

Warning:
The signer certificate will expire within six months.

C:\Documents and Settings\thanooj>

-----------------------Note----------------------
Enter Password for keystore and myself should be differ.

You can also ref. here for more details

No comments: