Domanda

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?

È stato utile?

Soluzione

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); 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top