8207250: setUseClientMode post handshake with the same value as before does not throw IAE

Reviewed-by: xuelei
This commit is contained in:
Weijun Wang 2018-07-19 00:14:29 +08:00
parent 8818f46285
commit a825fe0a2d
2 changed files with 20 additions and 16 deletions

View file

@ -393,6 +393,13 @@ class TransportContext implements ConnectionContext, Closeable {
}
void setUseClientMode(boolean useClientMode) {
// Once handshaking has begun, the mode can not be reset for the
// life of this engine.
if (handshakeContext != null || isNegotiated) {
throw new IllegalArgumentException(
"Cannot change mode after SSL traffic has started");
}
/*
* If we need to change the client mode and the enabled
* protocols and cipher suites haven't specifically been
@ -400,13 +407,6 @@ class TransportContext implements ConnectionContext, Closeable {
* default ones.
*/
if (sslConfig.isClientMode != useClientMode) {
// Once handshaking has begun, the mode can not be reset for the
// life of this engine.
if (handshakeContext != null || isNegotiated) {
throw new IllegalArgumentException(
"Cannot change mode after SSL traffic has started");
}
if (sslContext.isDefaultProtocolVesions(
sslConfig.enabledProtocols)) {
sslConfig.enabledProtocols =