public synchronized void processOutput(ByteBuffer buffer) throws SSLException {
		if (buffer.hasRemaining()) {
			do {
				SSLEngineResult result = mEngine.wrap(buffer, mOutboundData);
				switch (result.getHandshakeStatus()) {
					case NEED_TASK:
						runSSLTasks();
						break;
					case NEED_UNWRAP:
						// Should not be possible
						throw new SSLException("Need unwrap during output");
					case NEED_WRAP:
						// Should not be possible
						throw new SSLException("Need wrap during output");
					default:
						break;
				}
				switch (result.getStatus()) {
					case BUFFER_OVERFLOW:
						sendOutboundData();
						break;
					case BUFFER_UNDERFLOW:
						// Should not be possible
						throw new SSLException("Buffer underflow during output");
					case CLOSED:
						mOutboundData.clear();
						return;
					default:
						break;
				}
			} while (buffer.hasRemaining());
			sendOutboundData();
		}
	}