Search in sources :

Example 1 with SSLTestConfig

use of org.apache.solr.util.SSLTestConfig in project lucene-solr by apache.

the class SolrTestCaseJ4 method buildSSLConfig.

private static SSLTestConfig buildSSLConfig() {
    SSLRandomizer sslRandomizer = SSLRandomizer.getSSLRandomizerForClass(RandomizedContext.current().getTargetClass());
    if (Constants.MAC_OS_X) {
        // see SOLR-9039
        // If a solution is found to remove this, please make sure to also update
        // TestMiniSolrCloudClusterSSL.testSslAndClientAuth as well.
        sslRandomizer = new SSLRandomizer(sslRandomizer.ssl, 0.0D, (sslRandomizer.debug + " w/ MAC_OS_X supressed clientAuth"));
    }
    SSLTestConfig result = sslRandomizer.createSSLTestConfig();
    log.info("Randomized ssl ({}) and clientAuth ({}) via: {}", result.isSSLMode(), result.isClientAuthMode(), sslRandomizer.debug);
    return result;
}
Also used : SSLTestConfig(org.apache.solr.util.SSLTestConfig) SSLRandomizer(org.apache.solr.util.RandomizeSSL.SSLRandomizer)

Example 2 with SSLTestConfig

use of org.apache.solr.util.SSLTestConfig in project lucene-solr by apache.

the class TestMiniSolrCloudClusterSSL method testSslAndClientAuth.

public void testSslAndClientAuth() throws Exception {
    assumeFalse("SOLR-9039: SSL w/clientAuth does not work on MAC_OS_X", Constants.MAC_OS_X);
    final SSLTestConfig sslConfig = new SSLTestConfig(true, true);
    HttpClientUtil.setSchemaRegistryProvider(sslConfig.buildClientSchemaRegistryProvider());
    System.setProperty(ZkStateReader.URL_SCHEME, "https");
    checkClusterWithNodeReplacement(sslConfig);
}
Also used : SSLTestConfig(org.apache.solr.util.SSLTestConfig)

Example 3 with SSLTestConfig

use of org.apache.solr.util.SSLTestConfig in project lucene-solr by apache.

the class TestMiniSolrCloudClusterSSL method testNoSsl.

public void testNoSsl() throws Exception {
    final SSLTestConfig sslConfig = new SSLTestConfig(false, false);
    HttpClientUtil.setSchemaRegistryProvider(sslConfig.buildClientSchemaRegistryProvider());
    System.setProperty(ZkStateReader.URL_SCHEME, "http");
    checkClusterWithNodeReplacement(sslConfig);
}
Also used : SSLTestConfig(org.apache.solr.util.SSLTestConfig)

Example 4 with SSLTestConfig

use of org.apache.solr.util.SSLTestConfig in project lucene-solr by apache.

the class TestMiniSolrCloudClusterSSL method getSslAwareClientWithNoClientCerts.

/**
   * Returns a new HttpClient that supports both HTTP and HTTPS (with the default test truststore), but 
   * has no keystore -- so servers requiring client authentication should fail.
   */
private static CloseableHttpClient getSslAwareClientWithNoClientCerts() throws Exception {
    // NOTE: This method explicitly does *NOT* use HttpClientUtil code because that
    // will muck with the global static HttpClientBuilder / SchemeRegistryProvider
    // and we can't do that and still test the entire purpose of what we are trying to test here.
    final SSLTestConfig clientConfig = new SSLTestConfig(true, false);
    final SSLConnectionSocketFactory sslFactory = clientConfig.buildClientSSLConnectionSocketFactory();
    assert null != sslFactory;
    final Registry<ConnectionSocketFactory> socketFactoryReg = RegistryBuilder.<ConnectionSocketFactory>create().register("https", sslFactory).register("http", PlainConnectionSocketFactory.INSTANCE).build();
    final HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(new PoolingHttpClientConnectionManager(socketFactoryReg));
    return builder.build();
}
Also used : SSLTestConfig(org.apache.solr.util.SSLTestConfig) PlainConnectionSocketFactory(org.apache.http.conn.socket.PlainConnectionSocketFactory) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) ConnectionSocketFactory(org.apache.http.conn.socket.ConnectionSocketFactory) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager)

Example 5 with SSLTestConfig

use of org.apache.solr.util.SSLTestConfig in project lucene-solr by apache.

the class SSLMigrationTest method test.

@Test
public void test() throws Exception {
    //Migrate from HTTP -> HTTPS -> HTTP
    assertReplicaInformation("http");
    testMigrateSSL(new SSLTestConfig(true, false));
    testMigrateSSL(new SSLTestConfig(false, false));
}
Also used : SSLTestConfig(org.apache.solr.util.SSLTestConfig) Test(org.junit.Test)

Aggregations

SSLTestConfig (org.apache.solr.util.SSLTestConfig)8 SSLRandomizer (org.apache.solr.util.RandomizeSSL.SSLRandomizer)2 ConnectionSocketFactory (org.apache.http.conn.socket.ConnectionSocketFactory)1 PlainConnectionSocketFactory (org.apache.http.conn.socket.PlainConnectionSocketFactory)1 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)1 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)1 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1