mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8207250: setUseClientMode post handshake with the same value as before does not throw IAE
Reviewed-by: xuelei
This commit is contained in:
parent
8818f46285
commit
a825fe0a2d
2 changed files with 20 additions and 16 deletions
|
@ -393,6 +393,13 @@ class TransportContext implements ConnectionContext, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUseClientMode(boolean useClientMode) {
|
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
|
* If we need to change the client mode and the enabled
|
||||||
* protocols and cipher suites haven't specifically been
|
* protocols and cipher suites haven't specifically been
|
||||||
|
@ -400,13 +407,6 @@ class TransportContext implements ConnectionContext, Closeable {
|
||||||
* default ones.
|
* default ones.
|
||||||
*/
|
*/
|
||||||
if (sslConfig.isClientMode != useClientMode) {
|
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(
|
if (sslContext.isDefaultProtocolVesions(
|
||||||
sslConfig.enabledProtocols)) {
|
sslConfig.enabledProtocols)) {
|
||||||
sslConfig.enabledProtocols =
|
sslConfig.enabledProtocols =
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4980882
|
* @bug 4980882 8207250
|
||||||
* @summary SSLEngine should enforce setUseClientMode
|
* @summary SSLEngine should enforce setUseClientMode
|
||||||
* @run main/othervm EngineEnforceUseClientMode
|
* @run main/othervm EngineEnforceUseClientMode
|
||||||
* @author Brad R. Wetmore
|
* @author Brad R. Wetmore
|
||||||
|
@ -190,14 +190,18 @@ public class EngineEnforceUseClientMode {
|
||||||
checkTransfer(appOut1, appIn2);
|
checkTransfer(appOut1, appIn2);
|
||||||
checkTransfer(appOut2, appIn1);
|
checkTransfer(appOut2, appIn1);
|
||||||
|
|
||||||
|
// Should not be able to set mode now, no matter if
|
||||||
|
// it is the same of different.
|
||||||
System.out.println("Try changing modes...");
|
System.out.println("Try changing modes...");
|
||||||
try {
|
for (boolean b : new Boolean[] {true, false}) {
|
||||||
ssle2.setUseClientMode(true);
|
try {
|
||||||
throw new RuntimeException(
|
ssle2.setUseClientMode(b);
|
||||||
"setUseClientMode(): " +
|
throw new RuntimeException(
|
||||||
"Didn't catch the exception properly");
|
"setUseClientMode(" + b + "): " +
|
||||||
} catch (IllegalArgumentException e) {
|
"Didn't catch the exception properly");
|
||||||
System.out.println("Caught the correct exception.");
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.out.println("Caught the correct exception.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue