private void logHandshakeStatus(ChannelHandlerContext ctx) {
    SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
    if (sslHandler != null) {
      sslHandler.handshakeFuture().addListener(future -> {
        if (!future.isSuccess()) {
          logger.debug("SSL handshake failed for channel: {}", ctx.channel(), future.cause());
          metrics.handshakeFailureCount.inc();
        }
      });
    }
  }
Listen to the handshake future if this is an SSL connection. Log and update metrics if the handshake failed.
@param ctx the {@link ChannelHandlerContext}.
ambry-rest/src/main/java/com/github/ambry/rest/ConnectionStatsHandler.java