/** * Perform an SSL handshake using the SSLEngine. * @param key the <code>SelectionKey</code> * @param byteBuffer The application <code>ByteBuffer</code> * @param inputBB The encrypted input <code>ByteBuffer</code> * @param outputBB The encrypted output <code>ByteBuffer</code> * @param sslEngine The SSLEngine used. * @param handshakeStatus The current handshake status * @param timeout The time the Selector will block waiting for bytes * @return byteBuffer the new ByteBuffer * @throw IOException if the handshake fail. */ public static ByteBuffer doHandshake(SelectionKey key, ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB, SSLEngine sslEngine, HandshakeStatus handshakeStatus) throws IOException { return doHandshake(key,byteBuffer,inputBB,outputBB,sslEngine, handshakeStatus,readTimeout); }
/** * Execute a non blocking SSL handshake. */ protected boolean doHandshake(int timeout) throws IOException{ HandshakeStatus handshakeStatus = HandshakeStatus.NEED_UNWRAP; boolean OK = true; final SSLWorkerThread workerThread = (SSLWorkerThread)Thread.currentThread(); try{ if ( handshake ) { byteBuffer = SSLUtils.doHandshake (key,byteBuffer,inputBB,outputBB,sslEngine, handshakeStatus,timeout); if (doRead(inputBB) == -1){ throw new EOFException(); } } } catch (EOFException ex) { Logger logger = SSLSelectorThread.logger(); if ( logger.isLoggable(Level.FINE) ){ logger.log(Level.FINE,"doHandshake",ex); } OK = false; } finally { workerThread.setOutputBB(outputBB); } return OK; }
if (protocolInfo.handshake){ try{ byteBuffer = SSLUtils.doHandshake(key,byteBuffer,inputBB,outputBB, sslEngine,handshakeStatus, SSLUtils.getReadTimeout());