sohaib
sohaib

Reputation: 13

JKS to BKS keystore

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.

Upvotes: 1

Views: 6055

Answers (2)

Setmax
Setmax

Reputation: 1034

just download the KeyStore Explorer and load your key which provided or made by keytool then go to menu and select tools->type and select bks

bks v1 for API<23(if you looking for bks for android)

this process can be done without keytool and just with KeyStore Explorer

Upvotes: 0

PixelsTech
PixelsTech

Reputation: 3347

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

Upvotes: 6

Related Questions