0

I've my p12 file and cer file provided by client.

I've using below code as to connect with server, but having SSSLHandshakeException always:

KeyStore trustStore = KeyStore.getInstance("BKS");
            trustStore.load(R.raw.trustore), 
                    password.toCharArray());
            SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
            HttpParams params = new BasicHttpParams();
            HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            registry.register(new Scheme("https", sf, 443));
            ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
            DefaultHttpClient defaultHttpClient=new DefaultHttpClient(ccm, params);

Note that I converted trustore(.bks file) using below cmd:

keytool -genseckey -alias alias_name -keystore truststore.bks -providerclass org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath bcprov-jdk15on-149.jar -storetype BKS
Pankaj
  • 833
  • 12
  • 35
  • We can try to help you, but you need to ask a question for that, which you have not done here. Please say why this code is not working and what you want it to do. – Adriaan Aug 28 '15 at 07:53
  • Try reading [Android volley self signed HTTPS trust anchor for certification path not found](http://stackoverflow.com/questions/32154115/android-volley-self-signed-https-trust-anchor-for-certification-path-not-found/32219177#32219177) to find if it is helpful for you or not – BNK Aug 28 '15 at 07:56
  • Hi, thanks for concern...using code, getting SSLHandshakeException always. – Pankaj Aug 28 '15 at 08:02

1 Answers1

0

Solved the issue by using correct BKS file. I learn with this issue that, don't try to solve issue only one sided, though try with all the probable solution with open mind. Even I still don't know that how to validate correct BKS file if we've .p12 and .cer files. But you must have to be correct keystore file for success connection. Below is the command which I used for converting BKS file:

keytool -importkeystore -srckeystore xyz.p12 -srcstoretype BKS -destkeystore new-store.bks -deststore type BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath bcprov-jdk15on-149.jar
Pankaj
  • 833
  • 12
  • 35