Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyStore error on java server: BKS not found

I get an error on this line:

final KeyStore keyStore = KeyStore.getInstance("BKS");

the error i get is:

java.security.KeyStoreException: BKS not found
    at java.security.KeyStore.getInstance(Unknown Source)
    at AppListen.<init>(AppListen.java:84)

i added bcprov-jdk16-146.jar to the "Referenced Libraries" but still no luck.

My overall program allows an android phone to be used as mouse and keyboard for a computer using an SSL socket connection. The android app has the same line with no errors.

What am i doing wrong?


EDIT:

Maybe this is common knowledge for most, but it wasn't for me, so for those like me this is what i did.

The reason i was using BKS was because that's the only format allowed by android, but i didnt know that you only needed it on the android side, you can use another format on the server and then make a copy of the key and convert it to BKS to use on the android, eliminating the need for BouncyCastle.

I used a JKS key for the server and than converted a copy of that key to BKS to use on the android using a program called portecle.

like image 299
Mike Alike Avatar asked Jul 27 '12 10:07

Mike Alike


2 Answers

This error indicates that keytool tries to instantiate a BKS keystore but no Cryptographic Service Provider (CSP) is able to provide such an implementation. BKS keystore type is a type implemented by the BouncyCastle CSP
So you have to install BouncyCastle provider with Java. Installing Providers
And Look into this also.

like image 55
Sumit Singh Avatar answered Sep 19 '22 00:09

Sumit Singh


Include BouncyCastle library in the project and add provider in code

Security.addProvider(new BouncyCastleProvider());
KeyStore keyStore = KeyStore.getInstance("BKS");
like image 23
Davide Avatar answered Nov 20 '22 16:11

Davide