List of usage examples for io.netty.handler.ssl SslHandler getHandshakeTimeoutMillis
public long getHandshakeTimeoutMillis()
From source file:org.waarp.common.crypto.ssl.WaarpSslUtility.java
License:Open Source License
/** * Wait for the handshake on the given channel (better to use addSslHandler when handler is added after channel is active) * /*www .j a va 2 s . com*/ * @param channel * @return True if the Handshake is done correctly */ public static boolean waitForHandshake(Channel channel) { final ChannelHandler handler = channel.pipeline().first(); if (handler instanceof SslHandler) { logger.debug("Start handshake SSL: " + channel); final SslHandler sslHandler = (SslHandler) handler; // Get the SslHandler and begin handshake ASAP. // Get notified when SSL handshake is done. Future<Channel> handshakeFuture = sslHandler.handshakeFuture(); try { handshakeFuture.await(sslHandler.getHandshakeTimeoutMillis() + 100); } catch (InterruptedException e1) { } logger.debug("Handshake: " + handshakeFuture.isSuccess() + ": " + channel, handshakeFuture.cause()); if (!handshakeFuture.isSuccess()) { channel.close(); return false; } return true; } else { logger.error("SSL Not found but connected: " + handler.getClass().getName()); return true; } }