Friday, April 5, 2013

Easily & quickly create keystore for SSL communication for Android

For Android, you need to create your keystore with the Bouncy Castle format, or else you will receive:
The "Wrong version for keystore" error.

1. put this jar in C:\jdk1.6.0_33\bin:
    bcprov-ext-jdk15on-148.jar

   This is the bouncycastle provider jar file (you can also download it directly from the bouncycastle site)

2. cd to: C:\jdk1.6.0_33\bin,
    Call this command:
    keytool -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath C:\jdk1.6.0_33\bin\bcprov-ext-jdk15on-148.jar -genkey -alias privkey -keystore privkeystore -dname "cn=privkey" -keypass foobar -storepass foobar

Thats it! the keystore, named: privkeystore will be palced in the C:\jdk1.6.0_33\bin.

Of course you can change the password, name of the keystore (its also very recommended).