Reputation: 1691
I am trying to connect to server using keystore which is provided by server team.
While sending service call to server first i created KeyStore Instance by using following api
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
It’s returning the keystore type as “BKS”.
The Keystore what server team sent is of type “.jks”(somename.jks) So, I am getting exception “Wrong version of key store”.
I tried by passing “JKS” to getInstance() of KeyStore by following way
KeyStore keystore = KeyStore.getInstance("JKS");
But here I am getting exception “KeyStore JKS implementation not found”.
Here is the piece of code:
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream instream = mContext.getAssets().open("somename.jks");
try {
trustStore.load(instream, "password".toCharArray());
} finally {
try {
instream.close();
} catch(Exception ignore) {
}
}
Please guide me to solve this problem.
Upvotes: 16
Views: 19199
Reputation: 554
Other option is to use KeyStore Explorer (downloadable executable for Mac and Windows available online) to switch to BKS (Bouncy Castle KeyStore). Should work good for Android. I had similar issues while using JKS.
Upvotes: 0
Reputation: 1512
I think Android support 'only' BouncyCastle KeyStores (known as BKS)... You still can use Portecle
To convert it from JKS to BKS, should work like a charm (at least it worked for me when trying to store my .CRT into a BKS format ! ;)
'only' meaning, easily here :p, else you'll have to manipulate stuffs
Upvotes: 27