Skip to content

Instantly share code, notes, and snippets.

@Ladicek

Ladicek/a.java

Created Oct 12, 2017
Embed
What would you like to do?
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