Source:
<code>protected void doProcessMessage(HandshakeMessage message) throws HandshakeException, GeneralSecurityException { switch (message.getMessageType()) { case HELLO_VERIFY_REQUEST: receivedHelloVerifyRequest((HelloVerifyRequest) message); break; case SERVER_HELLO: receivedServerHello((ServerHello) message); break; case CERTIFICATE: receivedServerCertificate((CertificateMessage) message); break; case SERVER_KEY_EXCHANGE: switch (getKeyExchangeAlgorithm()) { case EC_DIFFIE_HELLMAN: receivedServerKeyExchange((ECDHServerKeyExchange) message); break; case PSK: break; case ECDHE_PSK: receivedServerKeyExchange((EcdhPskServerKeyExchange) message); break; case NULL: LOGGER.info("Received unexpected ServerKeyExchange message in NULL key exchange mode."); break; default: throw new HandshakeException( String.format("Unsupported key exchange algorithm %s", getKeyExchangeAlgorithm().name()), new AlertMessage(AlertLevel.FATAL, AlertDescription.HANDSHAKE_FAILURE, message.getPeer())); } <START> handshakeMessages.add(message); <END> break; case CERTIFICATE_REQUEST: certificateRequest = (CertificateRequest) message; handshakeMessages.add(message); break; case SERVER_HELLO_DONE: receivedServerHelloDone((ServerHelloDone) message); expectChangeCipherSpecMessage(); break; case FINISHED: receivedServerFinished((Finished) message); break; default: throw new HandshakeException( String.format("Received unexpected handshake message [%s] from peer %s", message.getMessageType(), message.getPeer()), new AlertMessage(AlertLevel.FATAL, AlertDescription.UNEXPECTED_MESSAGE, message.getPeer())); } }</code><technical_language>~(clearly a details) I feel this is a bit strange call handshakeMessages.add(message) in generic doProcessMessage in specific processing method (like receivedServerHello).~ Fixed in next commit</technical_language>

Target:
protected void doProcessMessage(HandshakeMessage message) throws HandshakeException, GeneralSecurityException { switch (message.getMessageType()) { case HELLO_VERIFY_REQUEST: receivedHelloVerifyRequest((HelloVerifyRequest) message); break; case SERVER_HELLO: receivedServerHello((ServerHello) message); break; case CERTIFICATE: receivedServerCertificate((CertificateMessage) message); break; case SERVER_KEY_EXCHANGE: switch (getKeyExchangeAlgorithm()) { case EC_DIFFIE_HELLMAN: receivedServerKeyExchange((ECDHServerKeyExchange) message); break; case PSK: break; case ECDHE_PSK: receivedServerKeyExchange((EcdhPskServerKeyExchange) message); break; case NULL: LOGGER.info("Received unexpected ServerKeyExchange message in NULL key exchange mode."); break; default: throw new HandshakeException( String.format("Unsupported key exchange algorithm %s", getKeyExchangeAlgorithm().name()), new AlertMessage(AlertLevel.FATAL, AlertDescription.HANDSHAKE_FAILURE, message.getPeer())); } break; case CERTIFICATE_REQUEST: certificateRequest = (CertificateRequest) message; break; case SERVER_HELLO_DONE: receivedServerHelloDone((ServerHelloDone) message); expectChangeCipherSpecMessage(); break; case FINISHED: receivedServerFinished((Finished) message); break; default: throw new HandshakeException( String.format("Received unexpected handshake message [%s] from peer %s", message.getMessageType(), message.getPeer()), new AlertMessage(AlertLevel.FATAL, AlertDescription.UNEXPECTED_MESSAGE, message.getPeer())); } }