Tuesday, November 3, 2015

Read Keystore jks file by using Java KeyTool

Below command to read the jks file and display the certificates it contains:

>keytool -list -keystore keystore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 2 entries
activation, Mar 13, 2013, trustedCertEntry, Certificate fingerprint (SHA1): 85:4B:73:CE:00:86:D6:1B:FE:95:17:3D:BB:E6:BE:02:BB:78:A4:2F
selfsigned, Mar 13, 2013, PrivateKeyEntry, Certificate fingerprint (SHA1): C5:0A:C4:AB:DA:80:03:F7:59:C7:D9:02:C5:D7:9A:97:08:7B:83:A0

Above data says, it has 2 certificate entries,
first one is alias name is "activation"
2nd one is alias name is "selfsigned"

Now we can export the above two entries into Certificates in CRT files as below 

>keytool -exportcert -file keystore.crt -keystore keystore.jks -alias activation 
Enter keystore password: 
Certificate stored in file  <keystore.crt>
>keytool -exportcert -file keystore1.crt -keystore keystore.jks -alias selfsigned
Enter keystore password: 
Certificate stored in file <keystore1.crt>

No comments:

Post a Comment