use of org.neo4j.test.server.InsecureTrustManager in project neo4j by neo4j.
the class HttpHeadersIT method runRequestAndGetHeaders.
private static Map<String, List<String>> runRequestAndGetHeaders(URI baseUri) throws Exception {
var uri = baseUri.resolve(txCommitEndpoint());
var request = HttpRequest.newBuilder(uri).header(ACCEPT, APPLICATION_JSON).POST(noBody()).build();
var trustAllSslContext = SSLContext.getInstance("TLS");
trustAllSslContext.init(null, new TrustManager[] { new InsecureTrustManager() }, null);
var client = HttpClient.newBuilder().sslContext(trustAllSslContext).connectTimeout(Duration.ofMinutes(1)).build();
var response = client.sendAsync(request, discarding()).get(1, TimeUnit.MINUTES);
assertEquals(200, response.statusCode());
return response.headers().map();
}
use of org.neo4j.test.server.InsecureTrustManager in project neo4j by neo4j.
the class HttpsAccessIT method startServer.
private void startServer(boolean httpEnabled, boolean httpsEnabled) throws Exception {
CommunityWebContainerBuilder serverBuilder = serverOnRandomPorts().usingDataDir(folder.directory(name.getMethodName()).toAbsolutePath().toString());
if (!httpEnabled) {
serverBuilder.withHttpDisabled();
}
if (httpsEnabled) {
serverBuilder.withHttpsEnabled();
}
testWebContainer = serverBuilder.build();
// Because we are generating a non-CA-signed certificate, we need to turn off verification in the client.
// This is ironic, since there is no proper verification on the CA side in the first place, but I digress.
TrustManager[] trustAllCerts = { new InsecureTrustManager() };
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
Aggregations