@Override public boolean isOutboundDone() { return engine.isOutboundDone(); }
/** * @return {@code True} if outbound data stream has closed, i.e. SSL engine encoded * <tt>close_notify</tt> message. */ boolean isOutboundDone() { return sslEngine.isOutboundDone(); }
@Override public boolean isOutboundDone() { return engine.isOutboundDone(); }
@Override public boolean isOutboundDone() { return delegate.isOutboundDone(); }
@Override public boolean isOutboundDone() { return delegate.isOutboundDone(); }
public boolean isOutboundDone() { return delegate.isOutboundDone(); }
@Override public boolean isOutboundDone() { return engine.isOutboundDone(); }
public boolean isOutboundDone() { return currentRef.get().isOutboundDone(); }
public boolean isOutboundDone() { return currentRef.get().isOutboundDone(); }
public boolean isOutboundDone() { return currentRef.get().isOutboundDone(); }
/** * Returns whether unwrap(ByteBuffer, ByteBuffer) will accept any more inbound data messages and * whether wrap(ByteBuffer, ByteBuffer) will produce any more outbound data messages. * * @return true if the TLSHandler will not consume anymore network data and will not produce any * anymore network data. */ public boolean isEngineClosed() { return (tlsEngine.isOutboundDone() && tlsEngine.isInboundDone()); }
public boolean isClosed() { return (engine.isOutboundDone() && engine.isInboundDone()); }
/** * Writes close_notify message to the network output buffer. * * @throws SSLException If wrap failed or SSL engine does not get closed * after wrap. * @return {@code True} if <tt>close_notify</tt> message was encoded, {@code false} if outbound * stream was already closed. */ boolean closeOutbound() throws SSLException { assert isHeldByCurrentThread(); if (!sslEngine.isOutboundDone()) { sslEngine.closeOutbound(); outNetBuf.clear(); SSLEngineResult res = sslEngine.wrap(handshakeBuf, outNetBuf); if (res.getStatus() != CLOSED) throw new SSLException("Incorrect SSL engine status after closeOutbound call [status=" + res.getStatus() + ", handshakeStatus=" + res.getHandshakeStatus() + ", ses=" + ses + ']'); outNetBuf.flip(); return true; } return false; }
if (!engine.isOutboundDone()) { ByteBuffer empty = ByteBuffer.wrap(new byte[0]); engine.closeOutbound();
@Test public void closeWhenSocketWriteError() throws Exception { SocketChannel mockChannel = mock(SocketChannel.class); Socket mockSocket = mock(Socket.class); when(mockChannel.socket()).thenReturn(mockSocket); when(mockSocket.isClosed()).thenReturn(true); when(mockEngine.isOutboundDone()).thenReturn(Boolean.FALSE); when(mockEngine.wrap(any(ByteBuffer.class), any(ByteBuffer.class))).thenAnswer((x) -> { // give the NioSslEngine something to write on its socket channel, simulating a TLS close // message nioSslEngine.myNetData.put("Goodbye cruel world".getBytes()); return new SSLEngineResult(CLOSED, FINISHED, 0, 0); }); when(mockChannel.write(any(ByteBuffer.class))).thenThrow(new ClosedChannelException()); nioSslEngine.close(mockChannel); verify(mockChannel, times(1)).write(any(ByteBuffer.class)); }
@Test public void closeWhenUnwrapError() throws Exception { SocketChannel mockChannel = mock(SocketChannel.class); Socket mockSocket = mock(Socket.class); when(mockChannel.socket()).thenReturn(mockSocket); when(mockSocket.isClosed()).thenReturn(true); when(mockEngine.isOutboundDone()).thenReturn(Boolean.FALSE); when(mockEngine.wrap(any(ByteBuffer.class), any(ByteBuffer.class))).thenReturn( new SSLEngineResult(BUFFER_OVERFLOW, FINISHED, 0, 0)); assertThatThrownBy(() -> nioSslEngine.close(mockChannel)).isInstanceOf(GemFireIOException.class) .hasMessageContaining("exception closing SSL session") .hasCauseInstanceOf(SSLException.class); }
@Test public void close() throws Exception { SocketChannel mockChannel = mock(SocketChannel.class); Socket mockSocket = mock(Socket.class); when(mockChannel.socket()).thenReturn(mockSocket); when(mockSocket.isClosed()).thenReturn(false); when(mockEngine.isOutboundDone()).thenReturn(Boolean.FALSE); when(mockEngine.wrap(any(ByteBuffer.class), any(ByteBuffer.class))).thenReturn( new SSLEngineResult(CLOSED, FINISHED, 0, 0)); nioSslEngine.close(mockChannel); assertThatThrownBy(() -> nioSslEngine.checkClosed()).isInstanceOf(IllegalStateException.class); nioSslEngine.close(mockChannel); }
&& !sslEngine.isOutboundDone()) { state = State.REHANDSHAKING; return doHandshakeStep(networkData);
/** * Attempt to finish wrapping close handshake bytes. * * @return {@code true} only if all bytes concerning close handshake messages have been wrapped. * @throws IOException if an unexpected IO exception occurs */ private boolean wrapCloseMessage() throws IOException { assert ! Thread.holdsLock(getUnwrapLock()); assert Thread.holdsLock(getWrapLock()); if (sinkConduit.isWriteShutdown()) { return true; } final ByteBuffer buffer = sendBuffer.getResource(); if (!engine.isOutboundDone() || !engine.isInboundDone()) { SSLEngineResult result; do { if (!handleWrapResult(result = engineWrap(Buffers.EMPTY_BYTE_BUFFER, buffer), true)) { return false; } } while (handleHandshake(result, true) && (result.getHandshakeStatus() != HandshakeStatus.NEED_UNWRAP || !engine.isOutboundDone())); handleWrapResult(result = engineWrap(Buffers.EMPTY_BYTE_BUFFER, buffer), true); if (!engine.isOutboundDone() || (result.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING && result.getHandshakeStatus() != HandshakeStatus.NEED_UNWRAP)) { return false; } } return true; }
oldState = stateUpdater.get(this); if (allAreSet(oldState, WRITE_COMPLETE)) { if (engine.isOutboundDone()) { connection.writeClosed(); if (engine.isOutboundDone()) { connection.writeClosed(); oldState = stateUpdater.get(this); if (allAreSet(oldState, WRITE_COMPLETE)) { if (engine.isOutboundDone()) { connection.writeClosed(); closeEngine(); if (engine.isOutboundDone()) { connection.writeClosed();