cbn
cbn

Reputation: 454

Wrong version of Keystore on Android 4.0.3

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?

Upvotes: 1

Views: 710

Answers (2)

Cukic0d
Cukic0d

Reputation: 5411

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...

Upvotes: 0

Fabian
Fabian

Reputation: 2713

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.

Upvotes: 1

Related Questions