Search in sources :

Example 51 with SSLParameters

use of javax.net.ssl.SSLParameters in project rest.li by linkedin.

the class TestHttpNettyClient method testClientPipelineFactory3Fail.

// Test that cannot set protocols in SSLParameters that don't have any match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory3Fail() throws NoSuchAlgorithmException {
    String[] requestedProtocols = { "Unsupported" };
    SSLParameters sslParameters = new SSLParameters();
    sslParameters.setProtocols(requestedProtocols);
    try {
        new HttpClientBuilder(_eventLoop, _scheduler).setSSLContext(SSLContext.getDefault()).setSSLParameters(sslParameters).buildRest();
    } catch (IllegalArgumentException e) {
        // Check exception message to make sure it's the expected one.
        Assert.assertEquals(e.getMessage(), "None of the requested protocols: [Unsupported] are found in SSLContext");
    }
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) Test(org.testng.annotations.Test)

Example 52 with SSLParameters

use of javax.net.ssl.SSLParameters in project rest.li by linkedin.

the class TestHttpNettyClient method testClientPipelineFactory3Pass.

// Test that can set protocols in SSLParameters that have at least one match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory3Pass() throws NoSuchAlgorithmException {
    String[] requestedProtocols = { "Unsupported", "TLSv1" };
    SSLParameters sslParameters = new SSLParameters();
    sslParameters.setProtocols(requestedProtocols);
    new HttpClientBuilder(_eventLoop, _scheduler).setSSLContext(SSLContext.getDefault()).setSSLParameters(sslParameters).buildRest();
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) Test(org.testng.annotations.Test)

Example 53 with SSLParameters

use of javax.net.ssl.SSLParameters in project rest.li by linkedin.

the class SimpleLoadBalancerStateTest method reset.

public void reset(boolean useSSL) {
    _executorService = new SynchronousExecutorService();
    _uriRegistry = new MockStore<UriProperties>();
    _clusterRegistry = new MockStore<ClusterProperties>();
    _serviceRegistry = new MockStore<ServiceProperties>();
    _clientFactories = new HashMap<String, TransportClientFactory>();
    _loadBalancerStrategyFactories = new HashMap<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>>();
    _loadBalancerStrategyFactories.put("random", new RandomLoadBalancerStrategyFactory());
    _loadBalancerStrategyFactories.put("degraderV3", new DegraderLoadBalancerStrategyFactoryV3());
    try {
        _sslContext = SSLContext.getDefault();
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
    _sslParameters = new SSLParameters();
    if (useSSL) {
        _clientFactories.put("https", new SimpleLoadBalancerTest.DoNothingClientFactory());
        _state = new SimpleLoadBalancerState(_executorService, _uriRegistry, _clusterRegistry, _serviceRegistry, _clientFactories, _loadBalancerStrategyFactories, _sslContext, _sslParameters, true);
    } else {
        _clientFactories.put("http", new SimpleLoadBalancerTest.DoNothingClientFactory());
        _state = new SimpleLoadBalancerState(_executorService, _uriRegistry, _clusterRegistry, _serviceRegistry, _clientFactories, _loadBalancerStrategyFactories);
    }
    FutureCallback<None> callback = new FutureCallback<None>();
    _state.start(callback);
    try {
        callback.get();
    } catch (Exception e) {
        Assert.fail("State start failed", e);
    }
}
Also used : DegraderLoadBalancerStrategyFactoryV3(com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SSLParameters(javax.net.ssl.SSLParameters) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory) FutureCallback(com.linkedin.common.callback.FutureCallback) SynchronousExecutorService(com.linkedin.d2.discovery.event.SynchronousExecutorService) RandomLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory) LoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.LoadBalancerStrategyFactory) RandomLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory) LoadBalancerStrategy(com.linkedin.d2.balancer.strategies.LoadBalancerStrategy) RandomLoadBalancerStrategy(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategy) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ExecutionException(java.util.concurrent.ExecutionException) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) None(com.linkedin.common.util.None)

Example 54 with SSLParameters

use of javax.net.ssl.SSLParameters in project undertow by undertow-io.

the class JDK9AlpnProvider method setProtocols.

@Override
public SSLEngine setProtocols(SSLEngine engine, String[] protocols) {
    SSLParameters sslParameters = engine.getSSLParameters();
    try {
        JDK_9_ALPN_METHODS.setApplicationProtocols().invoke(sslParameters, (Object) protocols);
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
    engine.setSSLParameters(sslParameters);
    return engine;
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 55 with SSLParameters

use of javax.net.ssl.SSLParameters in project keywhiz by square.

the class EndpointIdentificationSocketFactory method prepareSocket.

private Socket prepareSocket(Socket socket) {
    SSLSocket sslSocket = (SSLSocket) socket;
    SSLParameters parameters = sslSocket.getSSLParameters();
    parameters.setEndpointIdentificationAlgorithm("LDAPS");
    sslSocket.setSSLParameters(parameters);
    return sslSocket;
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) SSLSocket(javax.net.ssl.SSLSocket)

Aggregations

SSLParameters (javax.net.ssl.SSLParameters)71 SSLSocket (javax.net.ssl.SSLSocket)16 Test (org.testng.annotations.Test)16 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)14 SSLContext (javax.net.ssl.SSLContext)13 SSLEngine (javax.net.ssl.SSLEngine)10 Test (org.junit.Test)10 ByteString (com.linkedin.data.ByteString)9 AsciiString (io.netty.util.AsciiString)9 InetSocketAddress (java.net.InetSocketAddress)6 SNIHostName (javax.net.ssl.SNIHostName)6 ArrayList (java.util.ArrayList)5 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)5 IOException (java.io.IOException)4 URI (java.net.URI)4 X509Certificate (java.security.cert.X509Certificate)4 Jedis (redis.clients.jedis.Jedis)4 JedisShardInfo (redis.clients.jedis.JedisShardInfo)4 FutureCallback (com.linkedin.common.callback.FutureCallback)3 HttpsConfigurator (com.sun.net.httpserver.HttpsConfigurator)3