diff --git a/security/jss/org/mozilla/jss/tests/JSSE_SSLClient.java b/security/jss/org/mozilla/jss/tests/JSSE_SSLClient.java index 260452c17b00..44f3c856eef8 100755 --- a/security/jss/org/mozilla/jss/tests/JSSE_SSLClient.java +++ b/security/jss/org/mozilla/jss/tests/JSSE_SSLClient.java @@ -366,7 +366,8 @@ public class JSSE_SSLClient { */ String [] Ciphers = {cipherName}; socket.setEnabledCipherSuites(Ciphers); - socket.setSoTimeout(30 * 1000); + // Set socket timeout to 10 sec + socket.setSoTimeout(10 * 1000); socket.startHandshake(); PrintWriter out = new PrintWriter( @@ -494,6 +495,183 @@ public class JSSE_SSLClient { /* tunneling Handshake was successful! */ } + /** + * Test communication with SSL server using TLS + */ + public void testTlsClient(String testCipher, + String testHost, + int testPort) { + + String javaVersion = System.getProperty("java.version"); + String lastCipher = null; + System.out.println("\nUsing java version " + javaVersion + "\n"); + System.out.println("Testing TLS Cipher list ..."); + JSSE_SSLClient sslSock = new JSSE_SSLClient(); + sslSock.setSslRevision("TLS"); + sslSock.setHost(testHost); + sslSock.setPort(testPort); + + if ( javaVersion.indexOf("1.4") == -1 ) { + // Validate Ciphers supported for TLS + + if ( testCipher != null ) { + // This try is for catching non supported cipher exception + try { + sslSock.setCipherSuite(testCipher); + sslSock.setEOF(testCipher); + String errStr = sslSock.validateConnection(); + while (!sslSock.isHandshakeCompleted()) { + // Put the main thread to sleep. In case we do not get + // any response within 10 sec, then we shutdown. + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { + System.out.println("Thread Interrupted ...\n"); + } + } + sslSock.clearHandshakeCompleted(); + } catch (Exception ex) { + System.out.println("JSSE_SSLCLient: Did not find " + + "any supported ciphers for JDK 1.4.x"); + } + } else { + // This try is for catching non supported cipher exception + try { + for(int i=0;i