Correctly update internal handshake state on beginHandshake()

Motivation:

We missed to correctly update the internal handshake state on beginHandshake() if we was able to finish the handshake directly. Also we not handled the case correctly when beginHandshake() was called after the first handshake was finished, which incorrectly throw an Error.

Modifications:

- Correctly set internal handshake state in all cases
- Correctly handle beginHandshake() once first handshake was finished.

Result:

Correctly handle OpenSslEngine.beginHandshake()
This commit is contained in:
Norman Maurer 2015-09-26 20:11:45 +02:00
parent 1485a87e25
commit 179cd9a4a1

View File

@ -1043,8 +1043,8 @@ public final class OpenSslEngine extends SSLEngine {
public synchronized void beginHandshake() throws SSLException {
switch (handshakeState) {
case NOT_STARTED:
handshake();
handshakeState = HandshakeState.STARTED_EXPLICITLY;
handshake();
break;
case STARTED_IMPLICITLY:
checkEngineClosed();
@ -1058,6 +1058,7 @@ public final class OpenSslEngine extends SSLEngine {
handshakeState = HandshakeState.STARTED_EXPLICITLY; // Next time this method is invoked by the user,
// we should raise an exception.
break;
case FINISHED:
case STARTED_EXPLICITLY:
throw RENEGOTIATION_UNSUPPORTED;
default: