Search in sources :

Example 1 with CommunityWebContainerBuilder

use of org.neo4j.server.helpers.CommunityWebContainerBuilder 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());
}
Also used : CommunityWebContainerBuilder(org.neo4j.server.helpers.CommunityWebContainerBuilder) InsecureTrustManager(org.neo4j.test.server.InsecureTrustManager) SecureRandom(java.security.SecureRandom) SSLContext(javax.net.ssl.SSLContext) InsecureTrustManager(org.neo4j.test.server.InsecureTrustManager) TrustManager(javax.net.ssl.TrustManager)

Aggregations

SecureRandom (java.security.SecureRandom)1 SSLContext (javax.net.ssl.SSLContext)1 TrustManager (javax.net.ssl.TrustManager)1 CommunityWebContainerBuilder (org.neo4j.server.helpers.CommunityWebContainerBuilder)1 InsecureTrustManager (org.neo4j.test.server.InsecureTrustManager)1