io.netty.handler.ssl.OpenSslContext Java Examples

The following examples show how to use io.netty.handler.ssl.OpenSslContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testProtocolHttp11SslConfiguration() {
	DisposableServer disposableServer =
			server.protocol(HttpProtocol.HTTP11)
			      .secure(spec -> spec.sslContext(builder))
			      .bindNow();
	assertTrue(protocols.isEmpty());
	assertTrue(OpenSsl.isAvailable() ? sslContext instanceof OpenSslContext :
	                                   sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #2
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testSslConfigurationProtocolHttp11_1() {
	DisposableServer disposableServer =
			server.secure(spec -> spec.sslContext(builder))
			      .protocol(HttpProtocol.HTTP11)
			      .bindNow();
	assertTrue(protocols.isEmpty());
	assertTrue(OpenSsl.isAvailable() ? sslContext instanceof OpenSslContext :
	                                   sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #3
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testSslConfigurationProtocolHttp11_2() {
	DisposableServer disposableServer =
			server.protocol(HttpProtocol.H2)
			      .secure(spec -> spec.sslContext(builder))
			      .protocol(HttpProtocol.HTTP11)
			      .bindNow();
	assertTrue(protocols.isEmpty());
	assertTrue(OpenSsl.isAvailable() ? sslContext instanceof OpenSslContext :
	                                   sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #4
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testProtocolH2SslConfiguration() {
	DisposableServer disposableServer =
			server.protocol(HttpProtocol.H2)
			      .secure(spec -> spec.sslContext(builder))
			      .bindNow();
	assertEquals(2, protocols.size());
	assertTrue(protocols.contains("h2"));
	assertTrue(io.netty.handler.ssl.SslProvider.isAlpnSupported(io.netty.handler.ssl.SslProvider.OPENSSL) ?
	                                       sslContext instanceof OpenSslContext :
	                                       sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #5
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testSslConfigurationProtocolH2_1() {
	DisposableServer disposableServer =
			server.secure(spec -> spec.sslContext(builder))
			      .protocol(HttpProtocol.H2)
			      .bindNow();
	assertEquals(2, protocols.size());
	assertTrue(protocols.contains("h2"));
	assertTrue(io.netty.handler.ssl.SslProvider.isAlpnSupported(io.netty.handler.ssl.SslProvider.OPENSSL) ?
	                                       sslContext instanceof OpenSslContext :
	                                       sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #6
Source File: SslProviderTests.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testSslConfigurationProtocolH2_2() {
	DisposableServer disposableServer =
			server.protocol(HttpProtocol.HTTP11)
			      .secure(spec -> spec.sslContext(builder))
			      .protocol(HttpProtocol.H2)
			      .bindNow();
	assertEquals(2, protocols.size());
	assertTrue(protocols.contains("h2"));
	assertTrue(io.netty.handler.ssl.SslProvider.isAlpnSupported(io.netty.handler.ssl.SslProvider.OPENSSL) ?
	                                       sslContext instanceof OpenSslContext :
	                                       sslContext instanceof JdkSslContext);
	disposableServer.disposeNow();
}
 
Example #7
Source File: SocketSslEchoTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Parameters(name =
        "{index}: serverEngine = {0}, clientEngine = {1}, renegotiation = {2}, " +
        "serverUsesDelegatedTaskExecutor = {3}, clientUsesDelegatedTaskExecutor = {4}, " +
        "autoRead = {5}, useChunkedWriteHandler = {6}, useCompositeByteBuf = {7}")
public static Collection<Object[]> data() throws Exception {
    List<SslContext> serverContexts = new ArrayList<SslContext>();
    serverContexts.add(SslContextBuilder.forServer(CERT_FILE, KEY_FILE).sslProvider(SslProvider.JDK).build());

    List<SslContext> clientContexts = new ArrayList<SslContext>();
    clientContexts.add(SslContextBuilder.forClient().sslProvider(SslProvider.JDK).trustManager(CERT_FILE).build());

    boolean hasOpenSsl = OpenSsl.isAvailable();
    if (hasOpenSsl) {
        serverContexts.add(SslContextBuilder.forServer(CERT_FILE, KEY_FILE)
                                            .sslProvider(SslProvider.OPENSSL).build());
        clientContexts.add(SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL)
                                            .trustManager(CERT_FILE).build());
    } else {
        logger.warn("OpenSSL is unavailable and thus will not be tested.", OpenSsl.unavailabilityCause());
    }

    List<Object[]> params = new ArrayList<Object[]>();
    for (SslContext sc: serverContexts) {
        for (SslContext cc: clientContexts) {
            for (RenegotiationType rt: RenegotiationType.values()) {
                if (rt != RenegotiationType.NONE &&
                    (sc instanceof OpenSslContext || cc instanceof OpenSslContext)) {
                    // TODO: OpenSslEngine does not support renegotiation yet.
                    continue;
                }

                final Renegotiation r;
                switch (rt) {
                    case NONE:
                        r = Renegotiation.NONE;
                        break;
                    case SERVER_INITIATED:
                        r = new Renegotiation(rt, sc.cipherSuites().get(sc.cipherSuites().size() - 1));
                        break;
                    case CLIENT_INITIATED:
                        r = new Renegotiation(rt, cc.cipherSuites().get(cc.cipherSuites().size() - 1));
                        break;
                    default:
                        throw new Error();
                }

                for (int i = 0; i < 32; i++) {
                    params.add(new Object[] {
                            sc, cc, r,
                            (i & 16) != 0, (i & 8) != 0, (i & 4) != 0, (i & 2) != 0, (i & 1) != 0 });
                }
            }
        }
    }

    return params;
}
 
Example #8
Source File: SocketSslEchoTest.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Parameters(name =
        "{index}: serverEngine = {0}, clientEngine = {1}, renegotiation = {2}, " +
        "serverUsesDelegatedTaskExecutor = {3}, clientUsesDelegatedTaskExecutor = {4}, " +
        "autoRead = {5}, useChunkedWriteHandler = {6}, useCompositeByteBuf = {7}")
public static Collection<Object[]> data() throws Exception {
    List<SslContext> serverContexts = new ArrayList<SslContext>();
    serverContexts.add(new JdkSslServerContext(CERT_FILE, KEY_FILE));

    List<SslContext> clientContexts = new ArrayList<SslContext>();
    clientContexts.add(new JdkSslClientContext(CERT_FILE));

    boolean hasOpenSsl = OpenSsl.isAvailable();
    if (hasOpenSsl) {
        serverContexts.add(new OpenSslServerContext(CERT_FILE, KEY_FILE));
        clientContexts.add(new OpenSslClientContext(CERT_FILE));
    } else {
        logger.warn("OpenSSL is unavailable and thus will not be tested.", OpenSsl.unavailabilityCause());
    }

    List<Object[]> params = new ArrayList<Object[]>();
    for (SslContext sc: serverContexts) {
        for (SslContext cc: clientContexts) {
            for (RenegotiationType rt: RenegotiationType.values()) {
                if (rt != RenegotiationType.NONE &&
                    (sc instanceof OpenSslContext || cc instanceof OpenSslContext)) {
                    // TODO: OpenSslEngine does not support renegotiation yet.
                    continue;
                }

                Renegotiation r;
                if (rt == RenegotiationType.NONE) {
                    r = Renegotiation.NONE;
                } else {
                    r = new Renegotiation(rt, "SSL_RSA_WITH_RC4_128_SHA");
                }

                for (int i = 0; i < 32; i++) {
                    params.add(new Object[] {
                            sc, cc, r,
                            (i & 16) != 0, (i & 8) != 0, (i & 4) != 0, (i & 2) != 0, (i & 1) != 0 });
                }
            }
        }
    }

    return params;
}