Skip to content

Instantly share code, notes, and snippets.

@ozzi-
Created December 28, 2018 15:26
Show Gist options
  • Select an option

  • Save ozzi-/b7ed3b5240bc99521facec033a89a637 to your computer and use it in GitHub Desktop.

Select an option

Save ozzi-/b7ed3b5240bc99521facec033a89a637 to your computer and use it in GitHub Desktop.
public class SecureHTTPClient {
public static CloseableHttpClient getSecureHTTPClient() {
try {
SSLContext sslContext = SSLContexts.createDefault();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
new String[]{"TLSv1.2"},
new String[]{"TLS_DHE_RSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"},
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment