Example usage for io.netty.handler.ssl SslContext isServer

List of usage examples for io.netty.handler.ssl SslContext isServer

Introduction

In this page you can find the example usage for io.netty.handler.ssl SslContext isServer.

Prototype

public final boolean isServer() 

Source Link

Document

Returns true if and only if this context is for server-side.

Usage

From source file:com.linecorp.armeria.server.VirtualHost.java

License:Apache License

static SslContext validateSslContext(SslContext sslContext) {
    if (sslContext != null && !sslContext.isServer()) {
        throw new IllegalArgumentException("sslContext: " + sslContext + " (expected: server context)");
    }//from w  w  w  .  j a  v  a  2 s.  c  o m
    return sslContext;
}

From source file:io.crate.protocols.ssl.SslConfigurationTest.java

@Test
public void testSslContextCreation() {
    Settings settings = Settings.builder()
            .put(SslConfigSettings.SSL_TRUSTSTORE_FILEPATH_SETTING_NAME, trustStoreFile.getAbsolutePath())
            .put(SslConfigSettings.SSL_TRUSTSTORE_PASSWORD_SETTING_NAME, TRUSTSTORE_PASSWORD)
            .put(SslConfigSettings.SSL_KEYSTORE_FILEPATH_SETTING_NAME, keyStoreFile.getAbsolutePath())
            .put(SslConfigSettings.SSL_KEYSTORE_PASSWORD_SETTING_NAME, KEYSTORE_PASSWORD)
            .put(SslConfigSettings.SSL_KEYSTORE_KEY_PASSWORD_SETTING_NAME, KEYSTORE_KEY_PASSWORD).build();
    SslContext sslContext = SslConfiguration.buildSslContext(settings);
    assertThat(sslContext.isServer(), is(true));
    assertThat(sslContext.cipherSuites(), not(empty()));
    // check that we don't offer NULL ciphers which do not encrypt
    assertThat(sslContext.cipherSuites(), not(hasItem(containsString("NULL"))));
}

From source file:io.grpc.netty.NettyServerBuilder.java

License:Apache License

/**
 * Sets the TLS context to use for encryption. Providing a context enables encryption. It must
 * have been configured with {@link GrpcSslContexts}, but options could have been overridden.
 *//*from w  w  w.ja  v  a  2  s.c  om*/
public NettyServerBuilder sslContext(SslContext sslContext) {
    if (sslContext != null) {
        checkArgument(sslContext.isServer(), "Client SSL context can not be used for server");
        GrpcSslContexts.ensureAlpnAndH2Enabled(sslContext.applicationProtocolNegotiator());
    }
    this.sslContext = sslContext;
    return this;
}