Package io.netty.handler.ssl

Examples of io.netty.handler.ssl.SslHandler


            return consumer.getConfiguration().getSslHandler();
        } else if (sslContext != null) {
            SSLEngine engine = sslContext.createSSLEngine();
            engine.setUseClientMode(false);
            engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
            return new SslHandler(engine);
        }

        return null;
    }
View Full Code Here


    protected void initChannel(Channel ch) throws Exception {
        // create a new pipeline
        ChannelPipeline channelPipeline = ch.pipeline();

        SslHandler sslHandler = configureClientSSLOnDemand();
        if (sslHandler != null) {
            //TODO  must close on SSL exception
            //sslHandler.setCloseOnSSLException(true);
            LOG.debug("Client SSL handler configured and added to the ChannelPipeline: {}", sslHandler);
            addToPipeline("ssl", channelPipeline, sslHandler);
View Full Code Here

        if (producer.getConfiguration().getSslHandler() != null) {
            return producer.getConfiguration().getSslHandler();
        } else if (sslContext != null) {
            SSLEngine engine = sslContext.createSSLEngine();
            engine.setUseClientMode(true);
            return new SslHandler(engine);
        }

        return null;
    }
View Full Code Here

        ObjectHelper.notNull(configuration, "configuration");
        return "netty4:" + getConfiguration().getProtocol() + "://" + getConfiguration().getHost() + ":" + getConfiguration().getPort();
    }
   
    protected SSLSession getSSLSession(ChannelHandlerContext ctx) {
        final SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
        SSLSession sslSession = null;
        if (sslHandler != null) {
            sslSession = sslHandler.engine().getSession();
        }
        return sslSession;
    }
View Full Code Here

      final ChannelFuture channelFuture = bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
              .childHandler(new ChannelInitializer() {
                @Override
                protected void initChannel(Channel ch) throws Exception {
                  if (useSecureWebSocket) {
                    final SslHandler sslHandler = SslHandlerFactory.buildSslHandler(esc);
                    ch.pipeline().addLast("ssl", sslHandler);
                  }
                  ch.pipeline().addLast("codec-http", new HttpServerCodec());
                  ch.pipeline().addLast("aggregator", new HttpObjectAggregator(65536));
                  ch.pipeline().addLast("handler", webSocketHandler);
View Full Code Here

        keyPassword = keyStorePassword;
      }

      keyStore = KeystoreFactory.getKeyStore(keyStorePath, keyStorePassword, keystoreType);
    }
    return new SslHandler(getSslEngine(keyStore, keyPassword));
  }
View Full Code Here

        this.sslEngineFactory = sslEngineFactory;
    }

    @Override
    public void configureNewPipeline(ChannelPipeline pipeline) {
        pipeline.addFirst(new SslHandler(sslEngineFactory.createSSLEngine(pipeline.channel().alloc())));
    }
View Full Code Here

                        if (null == lifecycleHandler) {
                            onNewConnection(newConnection, subscriber);
                        } else {
                            @SuppressWarnings("unchecked")
                            ConnectionLifecycleHandler<I, O> handler = (ConnectionLifecycleHandler<I, O>) lifecycleHandler;
                            SslHandler sslHandler = pipeline.get(SslHandler.class);
                            if (null == sslHandler) {
                                handler.setConnection(newConnection);
                                onNewConnection(newConnection, subscriber);
                            } else {
                                sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<? super Channel>>() {
                                    @Override
                                    public void operationComplete(Future<? super Channel> future) throws Exception {
                                        onNewConnection(newConnection, subscriber);
                                    }
                                });
View Full Code Here

          // Attach the actual handler

          SSLEngine sslEngine = SSLEngineFactory.create(sslMode, context);

          final SslHandler sslHandler = new SslHandler(sslEngine);

          channel.pipeline().addFirst("ssl", sslHandler);

          try {

            sslHandler.handshakeFuture().syncUninterruptibly();

          }
          catch (Exception e) {

            // Retry with no SSL
            if (sslMode == SSLMode.Prefer) {
              return connect(SSLMode.Disable, address, context);
            }

            throw e;
          }

        }
        else if (sslMode.isRequired()) {

          throw new IOException("SSL not allowed by server");
        }

      }

      try {

        startup(protocol, context);

        if (sslMode == SSLMode.VerifyFull) {

          SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
          if (sslHandler != null) {

            String hostname;
            if (address instanceof InetSocketAddress) {
              hostname = ((InetSocketAddress) address).getHostString();
            }
            else {
              hostname = "";
            }

            verifyHostname(hostname, sslHandler.engine().getSession());
          }

        }

      }
View Full Code Here

        SSLEngine engine =
            SecureChatSslContextFactory.getServerContext().createSSLEngine();
        engine.setUseClientMode(false);

        p.addLast("ssl", new SslHandler(engine));
        p.addLast("unificationA", new PortUnificationServerHandler(false, detectGzip));
        p.removeAndForward(this);
    }
View Full Code Here

TOP

Related Classes of io.netty.handler.ssl.SslHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.