Package io.netty.handler.ssl

Examples of io.netty.handler.ssl.SslHandler


    try {
      if (this.isTls.compareAndSet(false, true)) {
        SSLEngine engine = this.sslContextBuilder.build().createSSLEngine();
        engine.setNeedClientAuth(false);
        engine.setUseClientMode(false);
        this.handler = new SslHandler(engine);
        this.prepareTls.compareAndSet(false, true);
      }
      return true;
    } catch (Exception e) {
      log.error(e.toString());
View Full Code Here


        final ChannelPipeline pipeline = channel.pipeline();

        final SSLEngine sslEngine = feedbackConnection.sslContext.createSSLEngine();
        sslEngine.setUseClientMode(true);

        pipeline.addLast("ssl", new SslHandler(sslEngine));
        pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(feedbackConnection.configuration.getReadTimeout()));
        pipeline.addLast("decoder", new ExpiredTokenDecoder());
        pipeline.addLast("handler", new FeedbackClientHandler(feedbackConnection));
      }
    });

    this.connectFuture = bootstrap.connect(this.environment.getFeedbackHost(), this.environment.getFeedbackPort());
    this.connectFuture.addListener(new GenericFutureListener<ChannelFuture>() {

      @Override
      public void operationComplete(final ChannelFuture connectFuture) {

        if (connectFuture.isSuccess()) {
          log.debug("{} connected; waiting for TLS handshake.", feedbackConnection.name);

          final SslHandler sslHandler = connectFuture.channel().pipeline().get(SslHandler.class);

          try {
            sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<Channel>>() {

              @Override
              public void operationComplete(final Future<Channel> handshakeFuture) {
                if (handshakeFuture.isSuccess()) {
                  log.debug("{} successfully completed TLS handshake.", feedbackConnection.name);
View Full Code Here

    final FeedbackServiceConnection feedbackConnection = this;

    return new Runnable() {
      @Override
      public void run() {
        final SslHandler sslHandler = feedbackConnection.connectFuture.channel().pipeline().get(SslHandler.class);

        if (feedbackConnection.connectFuture.isCancellable()) {
          feedbackConnection.connectFuture.cancel(true);
        } else if (sslHandler != null && sslHandler.handshakeFuture().isCancellable()) {
          sslHandler.handshakeFuture().cancel(true);
        } else {
          feedbackConnection.connectFuture.channel().close();
        }
      }
    };
View Full Code Here

    bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) throws Exception {
        channel.pipeline().addLast("ssl", new SslHandler(SSLTestUtil.createSSLEngineForMockServer()));
        channel.pipeline().addLast("encoder", new ApnsErrorEncoder());
        channel.pipeline().addLast("decoder", new ApnsPushNotificationDecoder());
        channel.pipeline().addLast("handler", new MockApnsServerHandler(server));
      }
    });
View Full Code Here

        final ChannelPipeline pipeline = channel.pipeline();

        final SSLEngine sslEngine = apnsConnection.sslContext.createSSLEngine();
        sslEngine.setUseClientMode(true);

        pipeline.addLast("ssl", new SslHandler(sslEngine));
        pipeline.addLast("decoder", new RejectedNotificationDecoder());
        pipeline.addLast("encoder", new ApnsPushNotificationEncoder());
        pipeline.addLast(ApnsConnection.PIPELINE_MAIN_HANDLER, new ApnsConnectionHandler(apnsConnection));
      }
    });

    log.debug("{} beginning connection process.", apnsConnection.name);
    this.connectFuture = bootstrap.connect(this.environment.getApnsGatewayHost(), this.environment.getApnsGatewayPort());
    this.connectFuture.addListener(new GenericFutureListener<ChannelFuture>() {

      @Override
      public void operationComplete(final ChannelFuture connectFuture) {
        if (connectFuture.isSuccess()) {
          log.debug("{} connected; waiting for TLS handshake.", apnsConnection.name);

          final SslHandler sslHandler = connectFuture.channel().pipeline().get(SslHandler.class);

          try {
            sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<Channel>>() {

              @Override
              public void operationComplete(final Future<Channel> handshakeFuture) {
                if (handshakeFuture.isSuccess()) {
                  log.debug("{} successfully completed TLS handshake.", apnsConnection.name);
View Full Code Here

    final ApnsConnection<T> apnsConnection = this;

    return new Runnable() {
      @Override
      public void run() {
        final SslHandler sslHandler = apnsConnection.connectFuture.channel().pipeline().get(SslHandler.class);

        if (apnsConnection.connectFuture.isCancellable()) {
          apnsConnection.connectFuture.cancel(true);
        } else if (sslHandler != null && sslHandler.handshakeFuture().isCancellable()) {
          sslHandler.handshakeFuture().cancel(true);
        } else {
          apnsConnection.connectFuture.channel().close();
        }
      }
    };
View Full Code Here

    final MockFeedbackServer server = this;
    bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) throws Exception {
        channel.pipeline().addLast("ssl", new SslHandler(SSLTestUtil.createSSLEngineForMockServer()));
        channel.pipeline().addLast("encoder", new ExpiredTokenEncoder());
        channel.pipeline().addLast("handler", new MockFeedbackServerHandler(server));
      }
    });
View Full Code Here

    @Override
    protected void initChannel(Channel ch) throws Exception {
        // create a new pipeline
        ChannelPipeline pipeline = ch.pipeline();
       
        SslHandler sslHandler = configureServerSSLOnDemand();
        if (sslHandler != null) {
            //TODO must close on SSL exception
            // sslHandler.setCloseOnSSLException(true);
            LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
            pipeline.addLast("ssl", sslHandler);
View Full Code Here

            engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
            if (consumer.getConfiguration().getSslContextParameters() == null) {
                // just set the enabledProtocols if the SslContextParameter doesn't set
                engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
            }
            return new SslHandler(engine);
        }

        return null;
    }
View Full Code Here

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

        SslHandler sslHandler = configureServerSSLOnDemand();
        if (sslHandler != null) {
            LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
            pipeline.addLast("ssl", sslHandler);
        }
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.