Created
November 5, 2012 11:09
-
-
Save pwntester/4016680 to your computer and use it in GitHub Desktop.
getNewHttpClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static HttpClient getNewHttpClient() { | |
try { | |
KeyStore trustStore = KeyStore.getInstance(KeyStore | |
.getDefaultType()); | |
trustStore.load(null, null); | |
SSLSocketFactory sf = new CustomSSLSocketFactory(trustStore); | |
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); | |
HttpParams params = new BasicHttpParams(); | |
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); | |
return new DefaultHttpClient(ccm, params); | |
} catch (Exception e) { | |
return new DefaultHttpClient(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment