Has anyone ever solved this problem without making the face of TrustManager ????
Seriously, all the answers "oh use a fake TrustManager and trust all certificates."
I have a root CA certificate that I must use to connect to the server.
Setting up SSLContext and using it with HttpsURLConnection works fine, but when I try to use it with ksoap (HttpsTransportSE), it forces me to give me an SSLHandshakeException.
I am using ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar, does anyone know if there are problems with this version?
Here is my code:
CertificateFactory cf = CertificateFactory.getInstance("X.509"); ca = cf.generateCertificate(caInput); System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN()); // Create a KeyStore containing our trusted CAs String keyStoreType = KeyStore.getDefaultType(); KeyStore keyStore = KeyStore.getInstance(keyStoreType); keyStore.load(null, null); keyStore.setCertificateEntry("ca", ca); caInput = this.getResources().openRawResource(R.raw.i1); java.security.cert.Certificate ci1; ci1 = cf.generateCertificate(caInput); System.out.println("i1=" + ((X509Certificate) ci1).getSubjectDN()); keyStore.setCertificateEntry("ci1", ci1); // Create a TrustManager that trusts the CAs in our KeyStore String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory tmf = TrustManagerFactory .getInstance(tmfAlgorithm); tmf.init(keyStore); // Create an SSLContext that uses our TrustManager SSLContext context = SSLContext.getInstance("TLS"); context.init(null, tmf.getTrustManagers(), null); URI u = URI.create("https://myurl/services/myservice"); SoapObject client = new SoapObject("", "dummy"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = client; HttpsTransportSE ht = new HttpsTransportSE(u.getHost(), u.getPort(), u.getPath(), 10000); ((HttpsServiceConnectionSE) ht.getServiceConnection()).setSSLSocketFactory(context.getSocketFactory()); ht.call("", envelope);
Thanks so much for any any help, whatever ....
source share