Search in sources :

Example 46 with SSLParameters

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

the class TestHttpNettyStreamClient method testClientPipelineFactory2Pass.

// Test that can set cipher suites in SSLParameters that have at least one match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory2Pass() throws NoSuchAlgorithmException {
    String[] requestedCipherSuites = { "Unsupported", "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA" };
    SSLParameters sslParameters = new SSLParameters();
    sslParameters.setCipherSuites(requestedCipherSuites);
    new HttpClientBuilder(_eventLoop, _scheduler).setSSLContext(SSLContext.getDefault()).setSSLParameters(sslParameters).buildStream();
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) AsciiString(io.netty.util.AsciiString) ByteString(com.linkedin.data.ByteString) Test(org.testng.annotations.Test)

Example 47 with SSLParameters

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

the class TestHttpNettyClient method testClientPipelineFactory2Pass.

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

Example 48 with SSLParameters

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

the class TestHttpNettyClient method testClientPipelineFactory2Fail.

// Test that cannot set cipher suites in SSLParameters that don't have any match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory2Fail() throws NoSuchAlgorithmException {
    String[] requestedCipherSuites = { "Unsupported" };
    SSLParameters sslParameters = new SSLParameters();
    sslParameters.setCipherSuites(requestedCipherSuites);
    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 cipher suites: [Unsupported] are found in SSLContext");
    }
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) Test(org.testng.annotations.Test)

Example 49 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 50 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)

Aggregations

SSLParameters (javax.net.ssl.SSLParameters)68 Test (org.testng.annotations.Test)16 SSLSocket (javax.net.ssl.SSLSocket)15 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)14 SSLContext (javax.net.ssl.SSLContext)13 Test (org.junit.Test)10 ByteString (com.linkedin.data.ByteString)9 AsciiString (io.netty.util.AsciiString)9 SSLEngine (javax.net.ssl.SSLEngine)8 InetSocketAddress (java.net.InetSocketAddress)6 SNIHostName (javax.net.ssl.SNIHostName)6 ArrayList (java.util.ArrayList)5 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)5 HttpsConfigurator (com.sun.net.httpserver.HttpsConfigurator)4 HttpsParameters (com.sun.net.httpserver.HttpsParameters)4 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