io.netty.handler.ssl.SniHandler Java Examples

The following examples show how to use io.netty.handler.ssl.SniHandler. 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: SslClientInitializerTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private ChannelHandler getServerHandler(
    boolean requireClientCert, PrivateKey privateKey, X509Certificate certificate)
    throws Exception {
  SslContext sslContext =
      SslContextBuilder.forServer(privateKey, certificate)
          .trustManager(InsecureTrustManagerFactory.INSTANCE)
          .clientAuth(requireClientCert ? ClientAuth.REQUIRE : ClientAuth.NONE)
          .build();
  return new SniHandler(
      hostname -> {
        sniHostReceived = hostname;
        return sslContext;
      });
}
 
Example #2
Source File: NettyPipelineSslUtils.java    From servicetalk with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if the {@link ChannelPipeline} is configured for SSL/TLS.
 *
 * @param pipeline The pipeline to check.
 * @return {@code true} if the pipeline is configured to use SSL/TLS.
 */
public static boolean isSslEnabled(ChannelPipeline pipeline) {
    return pipeline.get(SslHandler.class) != null || pipeline.get(SniHandler.class) != null;
}