8023147: Test DisabledShortRSAKeys.java intermittent failed
Reviewed-by: mullan
This commit is contained in:
parent
a3d0dbcdd9
commit
cc6f28352f
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2013, 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
|
||||||
@ -152,12 +152,9 @@ public class DisabledShortRSAKeys {
|
|||||||
serverReady = true;
|
serverReady = true;
|
||||||
|
|
||||||
try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
|
try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
|
||||||
InputStream sslIS = sslSocket.getInputStream();
|
try (InputStream sslIS = sslSocket.getInputStream()) {
|
||||||
OutputStream sslOS = sslSocket.getOutputStream();
|
sslIS.read();
|
||||||
|
}
|
||||||
sslIS.read();
|
|
||||||
sslOS.write('A');
|
|
||||||
sslOS.flush();
|
|
||||||
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"RSA keys shorter than 1024 bits should be disabled");
|
"RSA keys shorter than 1024 bits should be disabled");
|
||||||
@ -194,12 +191,10 @@ public class DisabledShortRSAKeys {
|
|||||||
sslSocket.setEnabledCipherSuites(
|
sslSocket.setEnabledCipherSuites(
|
||||||
new String[] {"TLS_DHE_RSA_WITH_AES_128_CBC_SHA"});
|
new String[] {"TLS_DHE_RSA_WITH_AES_128_CBC_SHA"});
|
||||||
|
|
||||||
InputStream sslIS = sslSocket.getInputStream();
|
try (OutputStream sslOS = sslSocket.getOutputStream()) {
|
||||||
OutputStream sslOS = sslSocket.getOutputStream();
|
sslOS.write('B');
|
||||||
|
sslOS.flush();
|
||||||
sslOS.write('B');
|
}
|
||||||
sslOS.flush();
|
|
||||||
sslIS.read();
|
|
||||||
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"RSA keys shorter than 1024 bits should be disabled");
|
"RSA keys shorter than 1024 bits should be disabled");
|
||||||
@ -317,6 +312,7 @@ public class DisabledShortRSAKeys {
|
|||||||
* Fork off the other side, then do your work.
|
* Fork off the other side, then do your work.
|
||||||
*/
|
*/
|
||||||
DisabledShortRSAKeys() throws Exception {
|
DisabledShortRSAKeys() throws Exception {
|
||||||
|
Exception startException = null;
|
||||||
try {
|
try {
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
startServer(true);
|
startServer(true);
|
||||||
@ -326,16 +322,20 @@ public class DisabledShortRSAKeys {
|
|||||||
startServer(false);
|
startServer(false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// swallow for now. Show later
|
startException = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for other side to close down.
|
* Wait for other side to close down.
|
||||||
*/
|
*/
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
serverThread.join();
|
if (serverThread != null) {
|
||||||
|
serverThread.join();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clientThread.join();
|
if (clientThread != null) {
|
||||||
|
clientThread.join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -344,36 +344,44 @@ public class DisabledShortRSAKeys {
|
|||||||
*/
|
*/
|
||||||
Exception local;
|
Exception local;
|
||||||
Exception remote;
|
Exception remote;
|
||||||
String whichRemote;
|
|
||||||
|
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
remote = serverException;
|
remote = serverException;
|
||||||
local = clientException;
|
local = clientException;
|
||||||
whichRemote = "server";
|
|
||||||
} else {
|
} else {
|
||||||
remote = clientException;
|
remote = clientException;
|
||||||
local = serverException;
|
local = serverException;
|
||||||
whichRemote = "client";
|
}
|
||||||
|
|
||||||
|
Exception exception = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check various exception conditions.
|
||||||
|
*/
|
||||||
|
if ((local != null) && (remote != null)) {
|
||||||
|
// If both failed, return the curthread's exception.
|
||||||
|
local.initCause(remote);
|
||||||
|
exception = local;
|
||||||
|
} else if (local != null) {
|
||||||
|
exception = local;
|
||||||
|
} else if (remote != null) {
|
||||||
|
exception = remote;
|
||||||
|
} else if (startException != null) {
|
||||||
|
exception = startException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If both failed, return the curthread's exception, but also
|
* If there was an exception *AND* a startException,
|
||||||
* print the remote side Exception
|
* output it.
|
||||||
*/
|
*/
|
||||||
if ((local != null) && (remote != null)) {
|
if (exception != null) {
|
||||||
System.out.println(whichRemote + " also threw:");
|
if (exception != startException && startException != null) {
|
||||||
remote.printStackTrace();
|
exception.addSuppressed(startException);
|
||||||
System.out.println();
|
}
|
||||||
throw local;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remote != null) {
|
// Fall-through: no exception to throw!
|
||||||
throw remote;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (local != null) {
|
|
||||||
throw local;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startServer(boolean newThread) throws Exception {
|
void startServer(boolean newThread) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user