Skip to content

Instantly share code, notes, and snippets.

@Ladicek
Created October 12, 2017 14:52
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 Ladicek/fe783b7f871e33f5cf4c403065714ddd to your computer and use it in GitHub Desktop.
Save Ladicek/fe783b7f871e33f5cf4c403065714ddd to your computer and use it in GitHub Desktop.
SSLContext sslContext = SSLContexts.custom()
.loadTrustMaterial((TrustStrategy) (chain, authType) -> true)
.build();
try (CloseableHttpClient httpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build()) {
String response = Executor.newInstance(httpClient)
.execute(Request.Get("https://localhost:8443/"))
.returnContent().asString();
assertThat(response).isEqualTo("Hello on port 8443, secure: true");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment