I am trying to convert a JKS keystore to BKS keystore using the convert-keystore utility (https://code.google.com/p/zip-signer/downloads/detail?name=convert-keystore-1.2.zip&can=2&q=).
On executing the command
> java -jar convert-keystore-1.2.jar server.keystore.jks server.keystore.bks
I am getting the following error:
>java.security.KeyStoreException: java.lang.NullPointerException
at org.bouncycastle.jce.provider.JDKKeyStore.engineSetKeyEntry(Unknown Source)
at java.security.KeyStore.setKeyEntry(KeyStore.java:880)
at kellinwood.keystore.Convert.main(Convert.java:89)
The keystore was was created via Java keystore utility:
keytool -genkey -alias myAlias -keyalg RSA -keysize 2048 -keystore server.keystore -validity 10000
The CSR was generated from this keystore using:
keytool -certreq -v -alias myAlias -file naavis_public.csr -keypass changeit -keystore server.keystore -storepass changeit
Then I imported the certificates from Thawte:
keytool -import -trustcacerts -alias SSL -keystore server.keystore.jks -file ssl.crt
>keytool -import -trustcacerts -alias INTERMEDIATE -keystore server.keystore.jks -file intermediate.crt
>keytool -import -trustcacerts -alias ROOT -keystore server.keystore.jks -file root.crt
This went through without any errors and am able to use this keystore in my application.
Kindly guide. I am using Java 1.6.45 and have the "java unlimited strength policy files" of the correct version. The keystore was also created on same java version.
Have also tried this process on Java 1.7.55. It produces same error.
Actually you can just use the keytool provided by Oracle JDK. Below command can be used to convert JKS to BKS.
keytool -importkeystore -srckeystore testkeys -srcstoretype JKS -srcstorepass passphrase -destkeystore testkeys.bks -deststoretype BKS -deststorepass password -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath C:\Personal\Work\lib\bouncycastle\bcprov-jdk15on-152.jar