1

I have code that creates its own Trust Store in order to connect to a private server.

When I run this on an HTC Desire C with Android 4.0.3 I get the exception: IOException: Wrong version of key store. at:

trustStore = KeyStore.getInstance("BKS");
InputStream in = getResources().openRawResource(R.raw.keystore);
trustStore.load(in, "xxxpasswordxxx".toCharArray());

on the last line where it does the load().

When I run the code on the following devices it works fine:

Nexus 7 and Android 4.4.4, Nexus 4 and Android 5.1, HTC One X+ and Android 4.2.2

The APK is the same (and the password is correct) for all devices. Any suggestions as to what I should look to try in order to fix it?

cbn
  • 404
  • 5
  • 16

2 Answers2

1

Maybe try to convert your keystore into a pkcs12 keystore.

openssl pkcs12 -export -inkey yourKeyFile.key -in yourCertKey.crt -out yourPkcs12Key.p12

and then use

trustStore = KeyStore.getInstance("PKCS12");
InputStream in = getResources().openRawResource(R.raw.keystore);
trustStore.load(in, "xxxpasswordxxx".toCharArray());

worked for me sometimes.

Fabian
  • 2,693
  • 2
  • 21
  • 33
0

Old question, but as not answered... For the one still looking, answer is there: Wrong version of keystore on android call

Because android 4.03- was using BKS-V1 (older version) and not BKS as the others...

Community
  • 1
  • 1
Cukic0d
  • 5,111
  • 2
  • 19
  • 48