Android and exception on introducing own custom key store -


i'm generating keystore certificate follows:

export classpath=/developer/bouncycastle/bcprov-jdk16-146.jar certstore=~/bitbucket/android/cooorijed/res/raw/mykeystore.bks if [ -a $certstore ];         rm $certstore || exit 1 fi keytool \         -importcert \         -v \         -trustcacerts \         -alias 0 \         -file <(openssl x509 -in mycert.pem) \         -keystore $certstore \         -storetype bks \         -provider org.bouncycastle.jce.provider.bouncycastleprovider \         -providerpath /developer/bouncycastle/bcprov-jdk16-146.jar \         -storepass password 

this generates key store without apparent problem. in eclipse clean android project , see "mykeystore.bks" in raw folder. load key store follows:

private keystore keystore() {     try {         keystore trusted = keystore.getinstance("bks");         inputstream in = context.getresources().openrawresource(r.raw.mykeystore);         try {             trusted.load(in, "password".tochararray()); // *throws exception*         } {         in.close();         }         return trusted;     } catch (exception e) {         throw new assertionerror(e);     } } 

i call method follows (i've removed exception handling make easier read here):

httpsurlconnection connection = (httpsurlconnection) url.openconnection(); keymanagerfactory kmf = keymanagerfactory.getinstance("x509"); kmf.init(keystore(), "password".tochararray()); 

however, line trusted.load(in, "password".tochararray()) causing "wrong version of key store" ioexception thrown. why that?

thanking in advance.

could using wrong version of bcprov jar? there different versions of , need choose 1 corresponds java sdk:

http://www.bouncycastle.org/latest_releases.html


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -