private SSLEngineResult.HandshakeStatus unwrap(SslEngineValidator peerValidator, boolean updateHandshakeResult) throws SSLException {
            // Unwrap regardless of whether there is data in the buffer to ensure that
            // handshake status is updated if required.
            peerValidator.netBuffer.flip(); // unwrap the data from peer
            SSLEngineResult sslEngineResult = sslEngine.unwrap(peerValidator.netBuffer, appBuffer);
            if (updateHandshakeResult) {
                handshakeResult = sslEngineResult;
            }
            peerValidator.netBuffer.compact();
            SSLEngineResult.HandshakeStatus handshakeStatus = sslEngineResult.getHandshakeStatus();
            switch (sslEngineResult.getStatus()) {
                case OK: break;
                case BUFFER_OVERFLOW:
                    appBuffer = Utils.ensureCapacity(appBuffer, sslEngine.getSession().getApplicationBufferSize());
                    break;
                case BUFFER_UNDERFLOW:
                    netBuffer = Utils.ensureCapacity(netBuffer, sslEngine.getSession().getPacketBufferSize());
                    // BUFFER_UNDERFLOW typically indicates that we need more data from peer,
                    // so return to process peer.
                    return null;
                case CLOSED:
                default:
                    throw new SSLException("Unexpected handshake status: " + sslEngineResult.getStatus());
            }
            return handshakeStatus;
        }
Validator used to verify dynamic update of keystore used in inter-broker communication.
The validator checks that a successful handshake can be performed using the keystore and
truststore configured on this SslFactory.
clients/src/main/java/org/apache/kafka/common/security/ssl/SslFactory.java