Created
June 3, 2014 07:59
-
-
Save tmarcus87/01f9c5228913c24d25f1 to your computer and use it in GitHub Desktop.
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 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