Skip to content

Instantly share code, notes, and snippets.

@Richie97
Created November 20, 2013 22:51
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 Richie97/7572622 to your computer and use it in GitHub Desktop.
Save Richie97/7572622 to your computer and use it in GitHub Desktop.
OkHttpClient providesOkHttpClient() {
OkHttpClient httpClient = new OkHttpClient();
SSLContext sslContext;
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);
} catch (GeneralSecurityException e) {
throw new AssertionError(); // The system has no TLS. Just give up.
}
httpClient.setSslSocketFactory(sslContext.getSocketFactory());
URL.setURLStreamHandlerFactory(httpClient);
return httpClient;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment