Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchAlgorithmException with KeyStore.getInstance in android application

Tags:

java

android

ssl

I write program in android for communication with server, I use SSL protocol, when I write this code

 KeyStore ks = KeyStore.getInstance( "JKS" );

I get this error

java.security.NoSuchAlgorithmException: KeyStore JKS implementation not found

How can I resolve my problem? My Algorithm is JKS.

Best Regards

like image 739
user3693568 Avatar asked Dec 20 '22 14:12

user3693568


1 Answers

Android does not support JKS keystore. However you can convert your JKS keystore to BouncyCastle BKS keystore and it will work.

@edit

You will need bcprov-jdk16-145.jar

keytool -importkeystore -srckeystore mytruststore.jks -destkeystore mytruststore.bks -srcstoretype JKS -deststoretype BKS -srcstorepass changeit -deststorepass changeit -provider org.bouncycastle.jce.provider.BouncyCastleProvider 

If your bcprov jar is in another directory add -providerpath path.

code taken from: http://www.knowledgebit.appspot.com/zahangirbd/TopicView.action;jsessionid=E2BZt_6bp4uFFbMyq42gWg?id=56001

like image 101
Than Avatar answered May 13 '23 09:05

Than