Example usage for io.netty.handler.ssl SslContextBuilder ciphers

List of usage examples for io.netty.handler.ssl SslContextBuilder ciphers

Introduction

In this page you can find the example usage for io.netty.handler.ssl SslContextBuilder ciphers.

Prototype

Iterable ciphers

To view the source code for io.netty.handler.ssl SslContextBuilder ciphers.

Click Source Link

Usage

From source file:org.conscrypt.testing.TestUtil.java

License:Apache License

public static SslContext newNettyClientContext(String cipher) {
    try {//  w  ww. ja v a  2s  .  com
        TestKeyStore server = TestKeyStore.getServer();
        SslContextBuilder ctx = SslContextBuilder.forClient()
                .sslProvider(io.netty.handler.ssl.SslProvider.OPENSSL)
                .trustManager((X509Certificate[]) server.getPrivateKey("RSA", "RSA").getCertificateChain());
        if (cipher != null) {
            ctx.ciphers(Collections.singletonList(cipher));
        }
        return ctx.build();
    } catch (SSLException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.conscrypt.testing.TestUtil.java

License:Apache License

public static SslContext newNettyServerContext(String cipher) {
    try {/* w  w  w  .  j ava 2  s . c o m*/
        PrivateKeyEntry server = TestKeyStore.getServer().getPrivateKey("RSA", "RSA");
        SslContextBuilder ctx = SslContextBuilder
                .forServer(server.getPrivateKey(), (X509Certificate[]) server.getCertificateChain())
                .sslProvider(io.netty.handler.ssl.SslProvider.OPENSSL);
        if (cipher != null) {
            ctx.ciphers(Collections.singletonList(cipher));
        }
        return ctx.build();
    } catch (SSLException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.springframework.boot.web.embedded.netty.SslServerCustomizer.java

License:Apache License

protected SslContextBuilder getContextBuilder() {
    SslContextBuilder builder = SslContextBuilder
            .forServer(getKeyManagerFactory(this.ssl, this.sslStoreProvider))
            .trustManager(getTrustManagerFactory(this.ssl, this.sslStoreProvider));
    if (this.ssl.getEnabledProtocols() != null) {
        builder.protocols(this.ssl.getEnabledProtocols());
    }//from   w ww .  ja v a  2 s  .co  m
    if (this.ssl.getCiphers() != null) {
        builder.ciphers(Arrays.asList(this.ssl.getCiphers()));
    }
    if (this.ssl.getClientAuth() == Ssl.ClientAuth.NEED) {
        builder.clientAuth(ClientAuth.REQUIRE);
    } else if (this.ssl.getClientAuth() == Ssl.ClientAuth.WANT) {
        builder.clientAuth(ClientAuth.OPTIONAL);
    }
    return builder;
}