Skip to content

Instantly share code, notes, and snippets.

@tmarcus87
Created June 3, 2014 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmarcus87/01f9c5228913c24d25f1 to your computer and use it in GitHub Desktop.
Save tmarcus87/01f9c5228913c24d25f1 to your computer and use it in GitHub Desktop.
public class HttpClientFactory {
public HttpClient insecureClient() {
try {
SSLSocketFactory sslSocketFactory =
new SSLSocketFactory(
new TrustSelfSignedStrategy(),
new AllowAllHostnameVerifier());
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", 8443, sslSocketFactory));
schemeRegistry.register(new Scheme("https", 443, sslSocketFactory));
return new DefaultHttpClient(new BasicClientConnectionManager(schemeRegistry));
} catch (KeyManagementException e) {
LOG.warn(ExceptionUtils.getStackTrace(e));
throw new HttpRequestException(e);
} catch (GeneralSecurityException e) {
LOG.warn(ExceptionUtils.getStackTrace(e));
throw new HttpRequestException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment