Has anybody ever solved this issue by NOT making a face TrustManager????
Seriously, all answers are "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 a SSLContext and using it via HttpsURLConnection works perfectly, but when I try to use it with ksoap (HttpsTransportSE), it keeps me giving me SSLHandshakeException.
I'm using ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar, anybody know if there are any issues with that 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 a lot in advance for any any any help, anything....