Question

I am using Koushik Dutta's Ion networking library for Android. I need to override SSL checks for debugging purposes. I've found out how to set my own SSL context and TrustManager using:

Ion.getDefault(context).getHttpClient().getSSLSocketMiddleware().setSSLContext(mySslContext); 
Ion.getDefault(context).getHttpClient().getSSLSocketMiddleware().setTrustManagers(myTrustManager);

but I can't figure out how to pass in my own HostnameVerifier. With HttpsUrlConnection it was as simple as

 HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(myHostNameVerifier);

Has anyone overridden SSL using ion? Any ideas?

Was it helpful?

Solution

I added a method to do this and sent a pull request to AndroidAsync on which Ion is dependent:

https://github.com/koush/AndroidAsync/pull/34

It's merged now so a simple call to setHostnameVerifier(HotstnameVerifier ver) will do the trick! Example:

Ion.getDefault(context).getHttpClient().getSSLSocketMiddleware().setHostnameVerifier(myHostnameVerifier); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top