提交 8947d386 编写于 作者: W weijun

7055363: jdk_security3 test target cleanup

Reviewed-by: alanb, xuelei
上级 15104845
...@@ -544,7 +544,7 @@ JDK_ALL_TARGETS += jdk_security3 ...@@ -544,7 +544,7 @@ JDK_ALL_TARGETS += jdk_security3
jdk_security3: $(call TestDirs, com/sun/security lib/security \ jdk_security3: $(call TestDirs, com/sun/security lib/security \
javax/security sun/security) javax/security sun/security)
$(call SharedLibraryPermissions,sun/security) $(call SharedLibraryPermissions,sun/security)
$(call RunOthervmBatch) $(call RunSamevmBatch)
# All security tests # All security tests
jdk_security: jdk_security1 jdk_security2 jdk_security3 jdk_security: jdk_security1 jdk_security2 jdk_security3
......
...@@ -450,73 +450,20 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all ...@@ -450,73 +450,20 @@ java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
# jdk_security # jdk_security
# Filed 6986868
sun/security/tools/jarsigner/crl.sh generic-all
# Filed 6951285, not sure how often this fails, last was Linux 64bit Fedora 9
sun/security/krb5/auto/MaxRetries.java generic-all
# Filed 6950930, fails on windows 32bit c1 and windows 64bit
sun/security/krb5/auto/IgnoreChannelBinding.java windows-all
# Filed 6950931, failing on all windows systems
sun/security/tools/jarsigner/crl.sh windows-all
# Filed 6950929, only seemed to fail on solaris sparcv9 (-d64)
# Failed on Linux -server 32bit too, making generic
sun/security/krb5/auto/BadKdc4.java generic-all
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3) # Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586 sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
sun/security/pkcs11/ec/ReadCertificates.java solaris-i586 sun/security/pkcs11/ec/ReadCertificates.java solaris-i586
sun/security/pkcs11/ec/ReadPKCS12.java solaris-i586 sun/security/pkcs11/ec/ReadPKCS12.java solaris-i586
sun/security/pkcs11/ec/TestCurves.java solaris-i586 sun/security/pkcs11/ec/TestCurves.java solaris-i586
sun/security/pkcs11/ec/TestECDSA.java solaris-i586 sun/security/pkcs11/ec/TestECDSA.java solaris-i586
sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586 #sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586
sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586 #sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-i586
# Failing on Solaris X64 (-d64 -server) with:
# GSSException: Failure unspecified at GSS-API level
# (Mechanism level: Specified version of key is not available (44))
sun/security/krb5/auto/BasicKrb5Test.java generic-all
# Solaris X86 failures, readjar.jks: No such file or directory
sun/security/tools/keytool/readjar.sh generic-all
# Fails with -ea -esa, but only on Solaris sparc? Suspect it is timing out
sun/security/tools/keytool/standard.sh generic-all
# Fails on Solaris 10 X64, address already in use
sun/security/krb5/auto/HttpNegotiateServer.java generic-all
# Fails on almost all platforms
# java.lang.UnsupportedClassVersionError: SerialTest :
# Unsupported major.minor version 51.0
# at java.lang.ClassLoader.defineClass1(Native Method)
sun/security/util/Oid/S11N.sh generic-all
# Fails on Fedora 9 32bit
# GSSException: Failure unspecified at GSS-API level (Mechanism level:
# Invalid argument (400) - Cannot find key of appropriate type to decrypt
# AP REP - DES CBC mode with MD5)
# at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:778)
sun/security/krb5/auto/NonMutualSpnego.java generic-all
# Fails on Solaris 10 sparc, GSSException: Failure unspecified at GSS-API level
# Also fails on Windows 2000 similar way
sun/security/krb5/auto/ok-as-delegate.sh generic-all
# Fails on Windows 2000, GSSException: Failure unspecified at GSS-API level
# (Mechanism level: Request is a replay (34))
sun/security/krb5/auto/ok-as-delegate-xrealm.sh generic-all
# Fails on Windows 2000, ExceptionInInitializerError # Directly references PKCS11 class
sun/security/mscapi/AccessKeyStore.sh generic-all sun/security/pkcs11/Provider/Absolute.java windows-x64
# Fails on Solaris 10, KrbException: Additional pre-authentication required (25) # Fails on Fedora 9/Ubuntu 10.04 64bit, PKCS11Exception: CKR_DEVICE_ERROR
sun/security/krb5/auto/basic.sh generic-all
# Fails on Fedora 9 64bit, PKCS11Exception: CKR_DEVICE_ERROR
sun/security/pkcs11/KeyAgreement/TestDH.java generic-all sun/security/pkcs11/KeyAgreement/TestDH.java generic-all
# Run too slow on Solaris 10 sparc # Run too slow on Solaris 10 sparc
...@@ -525,18 +472,10 @@ sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java s ...@@ -525,18 +472,10 @@ sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java s
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ServerTimeout.java solaris-sparc sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ServerTimeout.java solaris-sparc
sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java solaris-sparc sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java solaris-sparc
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh solaris-sparc sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh solaris-sparc
sun/security/tools/keytool/AltProviderPath.sh solaris-sparc
# Solaris 10 sparc, passed/failed confusion? java.security.ProviderException: update() failed # Solaris 10 sparc, passed/failed confusion? java.security.ProviderException: update() failed
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java generic-all sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java generic-all
# Seem really slow on Solaris sparc, being excluded just for timing reasons
sun/security/tools/jarsigner/AlgOptions.sh solaris-sparc
sun/security/tools/jarsigner/nameclash.sh solaris-sparc
sun/security/krb5/auto/basic.sh solaris-sparc
sun/security/provider/PolicyFile/getinstance/getinstance.sh solaris-sparc
sun/security/tools/jarsigner/samename.sh solaris-sparc
# Othervm, sparc, NoRouteToHostException: Cannot assign requested address # Othervm, sparc, NoRouteToHostException: Cannot assign requested address
sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
...@@ -544,49 +483,13 @@ sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all ...@@ -544,49 +483,13 @@ sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
# Solaris sparc and sparcv9 -server, timeout # Solaris sparc and sparcv9 -server, timeout
sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java generic-all sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java generic-all
# Failed on solaris 10 sparc, othervm mode, "js.jks: No such file or directory"
# Also, cannot verify signature on solaris i586 -server
sun/security/tools/jarsigner/concise_jarsigner.sh generic-all
# Various failures on Linux Fedora 9 X64, othervm mode # Various failures on Linux Fedora 9 X64, othervm mode
lib/security/cacerts/VerifyCACerts.java generic-all
sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java generic-all sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java generic-all
sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java generic-all sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java generic-all
sun/security/tools/jarsigner/oldsig.sh generic-all
# Various failures on Linux Fedora 9 X64, othervm mode # Various failures on Linux Fedora 9 X64, othervm mode
sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# Solaris sparcv9: Failed to parse input emptysubject.jks: No such file or directory
sun/security/tools/keytool/emptysubject.sh generic-all
# Fails on OpenSolaris, missing classes, slow on Solaris sparc
sun/security/ec/TestEC.java generic-all
# Problems with windows x64
sun/security/mscapi/IsSunMSCAPIAvailable.sh windows-x64
sun/security/mscapi/RSAEncryptDecrypt.sh windows-x64
# Exception in test solaris-sparc -client -server, no windows
sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java solaris-all
# Solaris sparc client, fails to compile?
sun/security/pkcs11/KeyStore/SecretKeysBasic.sh solaris-all
# Fails on OpenSolaris java.net.BindException: Address already in use
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java generic-all
# Timeout on solaris-sparcv9 or ArrayIndexOutOfBoundsException?
sun/security/rsa/TestKeyPairGeneratorLength.java solaris-all
sun/security/rsa/TestSignatures.java solaris-all
# Do not seem to run on windows machines? dll missing?
sun/security/tools/jarsigner/emptymanifest.sh windows-all
# Files does not exist or no encoding? solaris-sparcv9
sun/security/tools/keytool/importreadall.sh solaris-all
sun/security/tools/keytool/selfissued.sh solaris-all
############################################################################ ############################################################################
# jdk_swing (not using samevm) # jdk_swing (not using samevm)
......
...@@ -43,8 +43,9 @@ public class IllegalURL { ...@@ -43,8 +43,9 @@ public class IllegalURL {
static void use(String f) throws Exception { static void use(String f) throws Exception {
System.out.println("Testing " + f + "..."); System.out.println("Testing " + f + "...");
System.setProperty("java.security.auth.login.config", f); System.setProperty("java.security.auth.login.config", f);
try { try (FileInputStream fis =
new FileInputStream(new URL(f).getFile().replace('/', File.separatorChar)); new FileInputStream(new URL(f).getFile().replace('/', File.separatorChar))) {
// do nothing
} catch (Exception e) { } catch (Exception e) {
System.out.println("Even old implementation does not support it. Ignored."); System.out.println("Even old implementation does not support it. Ignored.");
return; return;
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.security.Provider;
import java.security.Security;
public class Providers {
public static void setAt(Provider p, int pos) throws Exception {
if (Security.getProvider(p.getName()) != null) {
Security.removeProvider(p.getName());
}
if (Security.insertProviderAt(p, pos) == -1) {
throw new Exception("cannot setAt");
}
}
}
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* @test * @test
* @bug 4633622 * @bug 4633622
* @summary bug in LoginContext when Configuration is subclassed * @summary bug in LoginContext when Configuration is subclassed
*
* @build ResetConfigModule ResetModule * @build ResetConfigModule ResetModule
* @run main ResetConfigModule * @run main ResetConfigModule
*/ */
...@@ -40,32 +39,42 @@ public class ResetConfigModule { ...@@ -40,32 +39,42 @@ public class ResetConfigModule {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Configuration.setConfiguration(new MyConfig()); Configuration previousConf = Configuration.getConfiguration();
ClassLoader previousCL = Thread.currentThread().getContextClassLoader();
LoginContext lc = new LoginContext("test");
try { try {
lc.login(); Thread.currentThread().setContextClassLoader(
throw new SecurityException("test 1 failed"); ResetConfigModule.class.getClassLoader());
} catch (LoginException le) { Configuration.setConfiguration(new MyConfig());
if (le.getCause() != null &&
le.getCause() instanceof SecurityException) { LoginContext lc = new LoginContext("test");
System.out.println("good so far"); try {
} else { lc.login();
throw le; throw new SecurityException("test 1 failed");
} catch (LoginException le) {
if (le.getCause() != null &&
le.getCause() instanceof SecurityException) {
System.out.println("good so far");
} else {
throw le;
}
} }
}
LoginContext lc2 = new LoginContext("test2"); LoginContext lc2 = new LoginContext("test2");
try { try {
lc2.login(); lc2.login();
throw new SecurityException("test 2 failed"); throw new SecurityException("test 2 failed");
} catch (LoginException le) { } catch (LoginException le) {
if (le.getCause() != null && if (le.getCause() != null &&
le.getCause() instanceof SecurityException) { le.getCause() instanceof SecurityException) {
System.out.println("test succeeded"); System.out.println("test succeeded");
} else { } else {
throw le; throw le;
}
} }
} finally {
Configuration.setConfiguration(previousConf);
Thread.currentThread().setContextClassLoader(previousCL);
} }
} }
} }
......
...@@ -28,11 +28,13 @@ ...@@ -28,11 +28,13 @@
* @library ../pkcs11 * @library ../pkcs11
* @library ../pkcs11/ec * @library ../pkcs11/ec
* @library ../pkcs11/sslecc * @library ../pkcs11/sslecc
* @library ../../../java/security/testlibrary
* @compile -XDignore.symbol.file TestEC.java * @compile -XDignore.symbol.file TestEC.java
* @run main TestEC * @run main TestEC
*/ */
import java.security.Provider; import java.security.Provider;
import java.security.Security;
/* /*
* Leverage the collection of EC tests used by PKCS11 * Leverage the collection of EC tests used by PKCS11
...@@ -51,6 +53,15 @@ import java.security.Provider; ...@@ -51,6 +53,15 @@ import java.security.Provider;
public class TestEC { public class TestEC {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ProvidersSnapshot snapshot = ProvidersSnapshot.create();
try {
main0(args);
} finally {
snapshot.restore();
}
}
public static void main0(String[] args) throws Exception {
Provider p = new sun.security.ec.SunEC(); Provider p = new sun.security.ec.SunEC();
System.out.println("Running tests with " + p.getName() + System.out.println("Running tests with " + p.getName() +
" provider...\n"); " provider...\n");
...@@ -67,6 +78,11 @@ public class TestEC { ...@@ -67,6 +78,11 @@ public class TestEC {
new TestECGenSpec().main(p); new TestECGenSpec().main(p);
new ReadPKCS12().main(p); new ReadPKCS12().main(p);
new ReadCertificates().main(p); new ReadCertificates().main(p);
// ClientJSSEServerJSSE fails on Solaris 11 when both SunEC and
// SunPKCS11-Solaris providers are enabled.
// Workaround:
// Security.removeProvider("SunPKCS11-Solaris");
new ClientJSSEServerJSSE().main(p); new ClientJSSEServerJSSE().main(p);
long stop = System.currentTimeMillis(); long stop = System.currentTimeMillis();
......
...@@ -36,7 +36,7 @@ public class NoSpnegoAsDefMech { ...@@ -36,7 +36,7 @@ public class NoSpnegoAsDefMech {
public static void main(String[] argv) throws Exception { public static void main(String[] argv) throws Exception {
System.setProperty("sun.security.jgss.mechanism", GSSUtil.GSS_SPNEGO_MECH_OID.toString()); System.setProperty("sun.security.jgss.mechanism", GSSUtil.GSS_SPNEGO_MECH_OID.toString());
try { try {
GSSManager.getInstance().createName("service@host", GSSName.NT_HOSTBASED_SERVICE, new Oid("1.3.6.1.5.5.2")); GSSManager.getInstance().createName("service@localhost", GSSName.NT_HOSTBASED_SERVICE, new Oid("1.3.6.1.5.5.2"));
} catch (GSSException e) { } catch (GSSException e) {
// This is OK, for example, krb5.conf is missing or other problems // This is OK, for example, krb5.conf is missing or other problems
} }
......
...@@ -72,10 +72,33 @@ public abstract class PKCS11Test { ...@@ -72,10 +72,33 @@ public abstract class PKCS11Test {
} }
public static void main(PKCS11Test test) throws Exception { public static void main(PKCS11Test test) throws Exception {
System.out.println("Beginning test run " + test.getClass().getName() + "..."); Provider[] oldProviders = Security.getProviders();
testDefault(test); try {
testNSS(test); System.out.println("Beginning test run " + test.getClass().getName() + "...");
testDeimos(test); testDefault(test);
testNSS(test);
testDeimos(test);
} finally {
Provider[] newProviders = Security.getProviders();
// Do not restore providers if nothing changed. This is especailly
// useful for ./Provider/Login.sh, where a SecurityManager exists.
if (oldProviders.length == newProviders.length) {
boolean found = false;
for (int i = 0; i<oldProviders.length; i++) {
if (oldProviders[i] != newProviders[i]) {
found = true;
break;
}
}
if (!found) return;
}
for (Provider p: newProviders) {
Security.removeProvider(p.getName());
}
for (Provider p: oldProviders) {
Security.addProvider(p);
}
}
} }
public static void testDeimos(PKCS11Test test) throws Exception { public static void testDeimos(PKCS11Test test) throws Exception {
...@@ -153,21 +176,21 @@ public abstract class PKCS11Test { ...@@ -153,21 +176,21 @@ public abstract class PKCS11Test {
return libdir; return libdir;
} }
static boolean loadNSPR(String libdir) throws Exception { protected static void safeReload(String lib) throws Exception {
// load NSS softoken dependencies in advance to avoid resolver issues
try { try {
System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4")); System.load(lib);
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
// GLIBC problem on older linux-amd64 machines if (e.getMessage().contains("already loaded")) {
if (libdir.contains("linux-amd64")) { return;
System.out.println(e);
System.out.println("NSS does not work on this platform, skipping.");
return false;
} }
throw e;
} }
System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4")); }
System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4"));
static boolean loadNSPR(String libdir) throws Exception {
// load NSS softoken dependencies in advance to avoid resolver issues
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4"));
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4"));
safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4"));
return true; return true;
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Test that the PKCS#11 KeyStore handles RSA, DSA, and EC keys * @summary Test that the PKCS#11 KeyStore handles RSA, DSA, and EC keys
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm AddPrivateKey
*/ */
import java.io.*; import java.io.*;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary make sure we can add a trusted cert to the NSS KeyStore module * @summary make sure we can add a trusted cert to the NSS KeyStore module
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm AddTrustedCert
*/ */
import java.io.*; import java.io.*;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary verify that NSS no-db mode works correctly * @summary verify that NSS no-db mode works correctly
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm Crypto
*/ */
import java.util.*; import java.util.*;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary make sure we can access the NSS softtoken KeyStore and use a private key * @summary make sure we can access the NSS softtoken KeyStore and use a private key
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm GetPrivateKey
*/ */
import java.util.*; import java.util.*;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary store a NSS PKCS11 PrivateKeyEntry to JKS KeyStore throws confusing NPE * @summary store a NSS PKCS11 PrivateKeyEntry to JKS KeyStore throws confusing NPE
* @author Wang Weijun * @author Wang Weijun
* @library .. * @library ..
* @run main/othervm JksSetPrivateKey
*/ */
import java.util.*; import java.util.*;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary make sure we can access the NSS trust anchor module * @summary make sure we can access the NSS trust anchor module
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm TrustAnchors
*/ */
import java.util.*; import java.util.*;
......
...@@ -44,8 +44,8 @@ public class SecmodTest extends PKCS11Test { ...@@ -44,8 +44,8 @@ public class SecmodTest extends PKCS11Test {
if (loadNSPR(LIBPATH) == false) { if (loadNSPR(LIBPATH) == false) {
return false; return false;
} }
System.load(LIBPATH + System.mapLibraryName("softokn3")); safeReload(LIBPATH + System.mapLibraryName("softokn3"));
System.load(LIBPATH + System.mapLibraryName("nssckbi")); safeReload(LIBPATH + System.mapLibraryName("nssckbi"));
DBDIR = System.getProperty("test.classes", ".") + SEP + "tmpdb"; DBDIR = System.getProperty("test.classes", ".") + SEP + "tmpdb";
System.setProperty("pkcs11test.nss.db", DBDIR); System.setProperty("pkcs11test.nss.db", DBDIR);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
* and verify their signatures * and verify their signatures
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @library ../../../../java/security/testlibrary
*/ */
import java.io.*; import java.io.*;
...@@ -62,7 +63,7 @@ public class ReadCertificates extends PKCS11Test { ...@@ -62,7 +63,7 @@ public class ReadCertificates extends PKCS11Test {
System.out.println("Provider does not support ECDSA, skipping..."); System.out.println("Provider does not support ECDSA, skipping...");
return; return;
} }
Security.insertProviderAt(p, 1); Providers.setAt(p, 1);
random = new SecureRandom(); random = new SecureRandom();
factory = CertificateFactory.getInstance("X.509"); factory = CertificateFactory.getInstance("X.509");
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Verify that we can parse ECPrivateKeys from PKCS#12 and use them * @summary Verify that we can parse ECPrivateKeys from PKCS#12 and use them
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @library ../../../../java/security/testlibrary
*/ */
import java.io.*; import java.io.*;
...@@ -52,7 +53,7 @@ public class ReadPKCS12 extends PKCS11Test { ...@@ -52,7 +53,7 @@ public class ReadPKCS12 extends PKCS11Test {
System.out.println("Provider does not support ECDSA, skipping..."); System.out.println("Provider does not support ECDSA, skipping...");
return; return;
} }
Security.insertProviderAt(p, 1); Providers.setAt(p, 1);
CertificateFactory factory = CertificateFactory.getInstance("X.509"); CertificateFactory factory = CertificateFactory.getInstance("X.509");
try { try {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Basic known answer test for ECDH * @summary Basic known answer test for ECDH
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @library ../../../../java/security/testlibrary
*/ */
import java.io.*; import java.io.*;
...@@ -59,7 +60,7 @@ public class TestECDH extends PKCS11Test { ...@@ -59,7 +60,7 @@ public class TestECDH extends PKCS11Test {
System.out.println("Provider does not support ECDH, skipping"); System.out.println("Provider does not support ECDH, skipping");
return; return;
} }
Security.insertProviderAt(p, 1); Providers.setAt(p, 1);
if (false) { if (false) {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", p); KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", p);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary basic test of SHA1withECDSA and NONEwithECDSA signing/verifying * @summary basic test of SHA1withECDSA and NONEwithECDSA signing/verifying
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @library ../../../../java/security/testlibrary
*/ */
import java.io.*; import java.io.*;
...@@ -115,7 +116,7 @@ public class TestECDSA extends PKCS11Test { ...@@ -115,7 +116,7 @@ public class TestECDSA extends PKCS11Test {
System.out.println("ECDSA not supported, skipping"); System.out.println("ECDSA not supported, skipping");
return; return;
} }
Security.insertProviderAt(provider, 1); Providers.setAt(provider, 1);
if (false) { if (false) {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", provider); KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", provider);
......
...@@ -394,47 +394,52 @@ public class CipherTest { ...@@ -394,47 +394,52 @@ public class CipherTest {
public static void main(PeerFactory peerFactory, KeyStore keyStore, public static void main(PeerFactory peerFactory, KeyStore keyStore,
String[] args) throws Exception { String[] args) throws Exception {
SSLContext reservedSSLContext = SSLContext.getDefault();
long time = System.currentTimeMillis(); try {
String relPath; long time = System.currentTimeMillis();
if ((args != null) && (args.length > 0) && args[0].equals("sh")) { String relPath;
relPath = pathToStoresSH; if ((args != null) && (args.length > 0) && args[0].equals("sh")) {
} else { relPath = pathToStoresSH;
relPath = pathToStores; } else {
relPath = pathToStores;
}
PATH = new File(System.getProperty("test.src", "."), relPath);
CipherTest.peerFactory = peerFactory;
System.out.print(
"Initializing test '" + peerFactory.getName() + "'...");
// secureRandom = new SecureRandom();
// secureRandom.nextInt();
// trustStore = readKeyStore(trustStoreFile);
CipherTest.keyStore = keyStore;
// keyStore = readKeyStore(keyStoreFile);
KeyManagerFactory keyFactory =
KeyManagerFactory.getInstance(
KeyManagerFactory.getDefaultAlgorithm());
keyFactory.init(keyStore, "test12".toCharArray());
keyManager = (X509ExtendedKeyManager)keyFactory.getKeyManagers()[0];
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
trustManager = (X509TrustManager)tmf.getTrustManagers()[0];
// trustManager = new AlwaysTrustManager();
SSLContext context = SSLContext.getInstance("TLS");
context.init(new KeyManager[] {keyManager},
new TrustManager[] {trustManager}, null);
SSLContext.setDefault(context);
CipherTest cipherTest = new CipherTest(peerFactory);
Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
"Server");
serverThread.setDaemon(true);
serverThread.start();
System.out.println("Done");
cipherTest.run();
time = System.currentTimeMillis() - time;
System.out.println("Done. (" + time + " ms)");
} finally {
SSLContext.setDefault(reservedSSLContext);
} }
PATH = new File(System.getProperty("test.src", "."), relPath);
CipherTest.peerFactory = peerFactory;
System.out.print(
"Initializing test '" + peerFactory.getName() + "'...");
// secureRandom = new SecureRandom();
// secureRandom.nextInt();
// trustStore = readKeyStore(trustStoreFile);
CipherTest.keyStore = keyStore;
// keyStore = readKeyStore(keyStoreFile);
KeyManagerFactory keyFactory =
KeyManagerFactory.getInstance(
KeyManagerFactory.getDefaultAlgorithm());
keyFactory.init(keyStore, "test12".toCharArray());
keyManager = (X509ExtendedKeyManager)keyFactory.getKeyManagers()[0];
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
trustManager = (X509TrustManager)tmf.getTrustManagers()[0];
// trustManager = new AlwaysTrustManager();
SSLContext context = SSLContext.getInstance("TLS");
context.init(new KeyManager[] {keyManager}, new TrustManager[] {trustManager}, null);
SSLContext.setDefault(context);
CipherTest cipherTest = new CipherTest(peerFactory);
Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
"Server");
serverThread.setDaemon(true);
serverThread.start();
System.out.println("Done");
cipherTest.run();
time = System.currentTimeMillis() - time;
System.out.println("Done. (" + time + " ms)");
} }
static abstract class PeerFactory { static abstract class PeerFactory {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @bug 6313675 6323647 * @bug 6313675 6323647
* @summary Verify that all ciphersuites work in FIPS mode * @summary Verify that all ciphersuites work in FIPS mode
* @library .. * @library ..
* @run main/othervm ClientJSSEServerJSSE
* @ignore JSSE supported cipher suites are changed with CR 6916074, * @ignore JSSE supported cipher suites are changed with CR 6916074,
* need to update this test case in JDK 7 soon * need to update this test case in JDK 7 soon
* @author Andreas Sterbenz * @author Andreas Sterbenz
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Verify that the SunJSSE trustmanager works correctly in FIPS mode * @summary Verify that the SunJSSE trustmanager works correctly in FIPS mode
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @run main/othervm TrustManagerTest
*/ */
import java.io.*; import java.io.*;
......
...@@ -48,32 +48,35 @@ public class TestCACerts extends PKCS11Test { ...@@ -48,32 +48,35 @@ public class TestCACerts extends PKCS11Test {
public void main(Provider p) throws Exception { public void main(Provider p) throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Security.addProvider(p); Security.addProvider(p);
String PROVIDER = p.getName(); try {
String javaHome = System.getProperty("java.home"); String PROVIDER = p.getName();
String caCerts = javaHome + SEP + "lib" + SEP + "security" + SEP + "cacerts"; String javaHome = System.getProperty("java.home");
InputStream in = new FileInputStream(caCerts); String caCerts = javaHome + SEP + "lib" + SEP + "security" + SEP + "cacerts";
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); InputStream in = new FileInputStream(caCerts);
ks.load(in, null); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
in.close(); ks.load(in, null);
for (Enumeration e = ks.aliases(); e.hasMoreElements(); ) { in.close();
String alias = (String)e.nextElement(); for (Enumeration e = ks.aliases(); e.hasMoreElements(); ) {
if (ks.isCertificateEntry(alias)) { String alias = (String)e.nextElement();
System.out.println("* Testing " + alias + "..."); if (ks.isCertificateEntry(alias)) {
X509Certificate cert = (X509Certificate)ks.getCertificate(alias); System.out.println("* Testing " + alias + "...");
PublicKey key = cert.getPublicKey(); X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
String alg = key.getAlgorithm(); PublicKey key = cert.getPublicKey();
if (alg.equals("RSA")) { String alg = key.getAlgorithm();
System.out.println("Signature algorithm: " + cert.getSigAlgName()); if (alg.equals("RSA")) {
cert.verify(key, PROVIDER); System.out.println("Signature algorithm: " + cert.getSigAlgName());
cert.verify(key, PROVIDER);
} else {
System.out.println("Skipping cert with key: " + alg);
}
} else { } else {
System.out.println("Skipping cert with key: " + alg); System.out.println("Skipping alias " + alias);
} }
} else {
System.out.println("Skipping alias " + alias);
} }
long stop = System.currentTimeMillis();
System.out.println("All tests passed (" + (stop - start) + " ms).");
} finally {
Security.removeProvider(p.getName());
} }
long stop = System.currentTimeMillis();
System.out.println("All tests passed (" + (stop - start) + " ms).");
} }
} }
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @summary Verify that all ciphersuites work (incl. ECC using NSS crypto) * @summary Verify that all ciphersuites work (incl. ECC using NSS crypto)
* @author Andreas Sterbenz * @author Andreas Sterbenz
* @library .. * @library ..
* @library ../../../../java/security/testlibrary
*/ */
import java.security.*; import java.security.*;
...@@ -45,7 +46,7 @@ public class ClientJSSEServerJSSE extends PKCS11Test { ...@@ -45,7 +46,7 @@ public class ClientJSSEServerJSSE extends PKCS11Test {
System.out.println("Provider does not support EC, skipping"); System.out.println("Provider does not support EC, skipping");
return; return;
} }
Security.insertProviderAt(p, 1); Providers.setAt(p, 1);
CipherTest.main(new JSSEFactory(), cmdArgs); CipherTest.main(new JSSEFactory(), cmdArgs);
Security.removeProvider(p.getName()); Security.removeProvider(p.getName());
} }
......
...@@ -86,7 +86,9 @@ public class PKCS12SameKeyId { ...@@ -86,7 +86,9 @@ public class PKCS12SameKeyId {
// Reads from JKS keystore and pre-calculate // Reads from JKS keystore and pre-calculate
KeyStore ks = KeyStore.getInstance("jks"); KeyStore ks = KeyStore.getInstance("jks");
ks.load(new FileInputStream(JKSFILE), PASSWORD); try (FileInputStream fis = new FileInputStream(JKSFILE)) {
ks.load(fis, PASSWORD);
}
for (int i=0; i<SIZE; i++) { for (int i=0; i<SIZE; i++) {
aliases[i] = "p" + i; aliases[i] = "p" + i;
byte[] enckey = cipher.doFinal( byte[] enckey = cipher.doFinal(
...@@ -103,11 +105,15 @@ public class PKCS12SameKeyId { ...@@ -103,11 +105,15 @@ public class PKCS12SameKeyId {
for (int i=0; i<SIZE; i++) { for (int i=0; i<SIZE; i++) {
p12.setKeyEntry(aliases[i], keys[i], certChains[i]); p12.setKeyEntry(aliases[i], keys[i], certChains[i]);
} }
p12.store(new FileOutputStream(P12FILE), PASSWORD); try (FileOutputStream fos = new FileOutputStream(P12FILE)) {
p12.store(fos, PASSWORD);
}
// Check private keys still match certs // Check private keys still match certs
p12 = KeyStore.getInstance("pkcs12"); p12 = KeyStore.getInstance("pkcs12");
p12.load(new FileInputStream(P12FILE), PASSWORD); try (FileInputStream fis = new FileInputStream(P12FILE)) {
p12.load(fis, PASSWORD);
}
for (int i=0; i<SIZE; i++) { for (int i=0; i<SIZE; i++) {
String a = "p" + i; String a = "p" + i;
X509Certificate x = (X509Certificate)p12.getCertificate(a); X509Certificate x = (X509Certificate)p12.getCertificate(a);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 5037004 * @bug 5037004
* @run main/othervm Comparator
* @summary Frivolous ClassCastExceptions thrown by SubjectCodeSource.implies * @summary Frivolous ClassCastExceptions thrown by SubjectCodeSource.implies
* *
* Note: if you want to see the java.security.debug output, * Note: if you want to see the java.security.debug output,
......
...@@ -40,28 +40,32 @@ public class ProviderTest { ...@@ -40,28 +40,32 @@ public class ProviderTest {
TrustManagerFactory tmf; TrustManagerFactory tmf;
KeyManagerFactory kmf; KeyManagerFactory kmf;
Security.addProvider(new MyProvider()); Provider extraProvider = new MyProvider();
Security.addProvider(extraProvider);
System.out.println("getting a javax SSLContext"); try {
sslc = SSLContext.getInstance("javax"); System.out.println("getting a javax SSLContext");
sslc.init(null, null, null); sslc = SSLContext.getInstance("javax");
System.out.println("\ngetting a com SSLContext"); sslc.init(null, null, null);
sslc = SSLContext.getInstance("com"); System.out.println("\ngetting a com SSLContext");
sslc.init(null, null, null); sslc = SSLContext.getInstance("com");
sslc.init(null, null, null);
System.out.println("\ngetting a javax TrustManagerFactory");
tmf = TrustManagerFactory.getInstance("javax"); System.out.println("\ngetting a javax TrustManagerFactory");
tmf.init((KeyStore) null); tmf = TrustManagerFactory.getInstance("javax");
System.out.println("\ngetting a com TrustManagerFactory"); tmf.init((KeyStore) null);
tmf = TrustManagerFactory.getInstance("com"); System.out.println("\ngetting a com TrustManagerFactory");
tmf.init((KeyStore) null); tmf = TrustManagerFactory.getInstance("com");
tmf.init((KeyStore) null);
System.out.println("\ngetting a javax KeyManagerFactory");
kmf = KeyManagerFactory.getInstance("javax"); System.out.println("\ngetting a javax KeyManagerFactory");
kmf.init((KeyStore) null, null); kmf = KeyManagerFactory.getInstance("javax");
System.out.println("\ngetting a com KeyManagerFactory"); kmf.init((KeyStore) null, null);
kmf = KeyManagerFactory.getInstance("com"); System.out.println("\ngetting a com KeyManagerFactory");
kmf.init((KeyStore) null, null); kmf = KeyManagerFactory.getInstance("com");
kmf.init((KeyStore) null, null);
} finally {
Security.removeProvider(extraProvider.getName());
}
} }
} }
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4814140 * @bug 4814140
* @summary AppInputStream: read can block a close * @summary AppInputStream: read can block a close
* @run main/othervm ReadBlocksClose
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4514971 * @bug 4514971
* @summary Verify applications do not read handshake data after failure * @summary Verify applications do not read handshake data after failure
* @run main/othervm ReadHandshake
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 6697270 * @bug 6697270
* @summary Inputstream dosent behave correct * @summary Inputstream dosent behave correct
* @run main/othervm ReadZeroBytes
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4413664 * @bug 4413664
* @summary remove mark/reset functionality from AppInputStream * @summary remove mark/reset functionality from AppInputStream
* @run main/othervm RemoveMarkReset
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test 1.3 01/03/08 * @test 1.3 01/03/08
* @bug 4378397 * @bug 4378397
* @summary JSSE socket output stream doesn't throw after socket is closed * @summary JSSE socket output stream doesn't throw after socket is closed
* @run main/othervm NoExceptionOnClose
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Jaya Hangal * @author Jaya Hangal
*/ */
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4330535 * @bug 4330535
* @summary Client should follow suite order in * @summary Client should follow suite order in
* SSLSocket.setEnabledCipherSuites() * SSLSocket.setEnabledCipherSuites()
* @run main/othervm CipherSuiteOrder
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Jaya Hangal * @author Jaya Hangal
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 6690018 * @bug 6690018
* @summary RSAClientKeyExchange NullPointerException * @summary RSAClientKeyExchange NullPointerException
* @run main/othervm RSAExport
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
/* /*
......
/* /*
* @test * @test
* @build TestThread Traffic Handler ServerHandler ServerThread ClientThread * @build TestThread Traffic Handler ServerHandler ServerThread ClientThread
* @run main/timeout=140 main * @run main/othervm/timeout=140 main
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @summary Make sure that different configurations of SSL sockets work * @summary Make sure that different configurations of SSL sockets work
*/ */
......
...@@ -24,7 +24,12 @@ ...@@ -24,7 +24,12 @@
/* /*
* @test * @test
* @bug 4453053 * @bug 4453053
* @summary If a server shuts down correctly during handshaking, the client doesn't see it. * @summary If a server shuts down correctly during handshaking, the client
* doesn't see it.
* @run main/othervm NullCerts
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
/* /*
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4432868 * @bug 4432868
* @summary A client-hello message may not always be read correctly * @summary A client-hello message may not always be read correctly
* @run main/othervm ClientHelloRead
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -154,23 +158,29 @@ public class ClientHelloRead { ...@@ -154,23 +158,29 @@ public class ClientHelloRead {
* we want to avoid URLspoofCheck failures in cases where the cert * we want to avoid URLspoofCheck failures in cases where the cert
* DN name does not match the hostname in the URL. * DN name does not match the hostname in the URL.
*/ */
HttpsURLConnection.setDefaultHostnameVerifier( HostnameVerifier reservedHV =
new NameVerifier()); HttpsURLConnection.getDefaultHostnameVerifier();
URL url = new URL("https://" + "localhost:" + serverPort
+ "/index.html");
BufferedReader in = null;
try { try {
in = new BufferedReader(new InputStreamReader( HttpsURLConnection.setDefaultHostnameVerifier(
url.openStream())); new NameVerifier());
String inputLine; URL url = new URL("https://" + "localhost:" + serverPort
System.out.print("Client recieved from the server: "); + "/index.html");
while ((inputLine = in.readLine()) != null) BufferedReader in = null;
System.out.println(inputLine); try {
in.close(); in = new BufferedReader(new InputStreamReader(
} catch (SSLException e) { url.openStream()));
if (in != null) String inputLine;
System.out.print("Client recieved from the server: ");
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close(); in.close();
throw e; } catch (SSLException e) {
if (in != null)
in.close();
throw e;
}
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
} }
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @summary Setting timeouts on SSLSockets immediately return null * @summary Setting timeouts on SSLSockets immediately return null
* after timeout occurs. This bug was fixed as part of 4393337, * after timeout occurs. This bug was fixed as part of 4393337,
* but this is another bug we want to check regressions against. * but this is another bug we want to check regressions against.
* @run main/timeout=140 SSLSocketTimeoutNulls * @run main/othervm/timeout=140 SSLSocketTimeoutNulls
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
/* /*
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2011, 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
...@@ -147,12 +147,18 @@ public class HttpsProtocols implements HostnameVerifier { ...@@ -147,12 +147,18 @@ public class HttpsProtocols implements HostnameVerifier {
Thread.sleep(50); Thread.sleep(50);
} }
HttpsURLConnection.setDefaultHostnameVerifier(this); HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
HttpsURLConnection.setDefaultHostnameVerifier(this);
URL url = new URL("https://localhost:" + serverPort + "/"); URL url = new URL("https://localhost:" + serverPort + "/");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
System.out.println("response is " + urlc.getResponseCode()); System.out.println("response is " + urlc.getResponseCode());
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
}
} }
public boolean verify(String hostname, SSLSession session) { public boolean verify(String hostname, SSLSession session) {
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4919147 * @bug 4919147
* @summary Support for token-based KeyStores * @summary Support for token-based KeyStores
* @run main/othervm BadKSProvider
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4919147 * @bug 4919147
* @summary Support for token-based KeyStores * @summary Support for token-based KeyStores
* @run main/othervm BadTSProvider
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4919147 * @bug 4919147
* @summary Support for token-based KeyStores * @summary Support for token-based KeyStores
* @run main/othervm GoodProvider
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 6207322 * @bug 6207322
* @summary SSLEngine is returning a premature FINISHED message when doing * @summary SSLEngine is returning a premature FINISHED message when doing
* an abbreviated handshake. * an abbreviated handshake.
* @run main/othervm RehandshakeFinished
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* This test may need some updating if the messages change order. * This test may need some updating if the messages change order.
* Currently I'm expecting that there is a simple renegotiation, with * Currently I'm expecting that there is a simple renegotiation, with
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 6492872 * @bug 6492872
* @summary Deadlock in SSLEngine * @summary Deadlock in SSLEngine
* @run main/othervm SSLEngineDeadlock
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Brad R. Wetmore * @author Brad R. Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4910892 * @bug 4910892
* @summary 4518403 was not properly fixed. hashcode should be hashCode. * @summary 4518403 was not properly fixed. hashcode should be hashCode.
* @run main/othervm HashCodeMissing
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 6447412 * @bug 6447412
* @summary Issue with socket.close() for ssl sockets when poweroff on * @summary Issue with socket.close() for ssl sockets when poweroff on
* other system * other system
* @run main/othervm AsyncSSLSocketClose
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import javax.net.ssl.*; import javax.net.ssl.*;
......
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
/* /*
* @test * @test
* @bug 4390659 * @bug 4390659
* @run main/othervm -Djavax.net.debug=all ClientModeClientAuth
* @summary setNeedClientAuth() isn't working after a handshaker is established * @summary setNeedClientAuth() isn't working after a handshaker is established
* @run main/othervm ClientModeClientAuth
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4836493 * @bug 4836493
* @summary Socket timeouts for SSLSockets causes data corruption. * @summary Socket timeouts for SSLSockets causes data corruption.
* @run main/othervm ClientTimeout
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4969799 * @bug 4969799
* @summary javax.net.ssl.SSLSocket.SSLSocket(InetAddress,int) shouldn't * @summary javax.net.ssl.SSLSocket.SSLSocket(InetAddress,int) shouldn't
* throw exception * throw exception
* @run main/othervm CloseSocketException
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* This is making sure that starting a new handshake throws the right * This is making sure that starting a new handshake throws the right
* exception. There is a similar test for SSLEngine. * exception. There is a similar test for SSLEngine.
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4403428 * @bug 4403428
* @summary Invalidating JSSE session on server causes SSLProtocolException * @summary Invalidating JSSE session on server causes SSLProtocolException
* @run main/othervm InvalidateServerSessionRenegotiate
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4429176 * @bug 4429176
* @summary need to sync up SSL sockets with merlin java.net changes * @summary need to sync up SSL sockets with merlin java.net changes
* @run main/othervm NewSocketMethods
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4404399 * @bug 4404399
* @summary When a layered SSL socket is closed, it should wait for close_notify * @summary When a layered SSL socket is closed, it should wait for close_notify
* @run main/othervm NonAutoClose
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4482446 * @bug 4482446
* @summary java.net.SocketTimeoutException on 98, NT, 2000 for JSSE * @summary java.net.SocketTimeoutException on 98, NT, 2000 for JSSE
* @run main/othervm ReuseAddr
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4748292 * @bug 4748292
* @summary Prevent/Disable reverse name lookups with JSSE SSL sockets * @summary Prevent/Disable reverse name lookups with JSSE SSL sockets
* @run main/othervm ReverseNameLookup
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4361124 4325806 * @bug 4361124 4325806
* @summary SSLServerSocket isn't throwing exceptions when negotiations are * @summary SSLServerSocket isn't throwing exceptions when negotiations are
* failing & java.net.SocketException: occures in Auth and clientmode * failing & java.net.SocketException: occures in Auth and clientmode
* @run main/othervm SSLSocketImplThrowsWrongExceptions
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4836493 * @bug 4836493
* @summary Socket timeouts for SSLSockets causes data corruption. * @summary Socket timeouts for SSLSockets causes data corruption.
* @run main/othervm ServerTimeout
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 6223624 * @bug 6223624
* @summary SSLSocket.setUseClientMode() fails to throw expected * @summary SSLSocket.setUseClientMode() fails to throw expected
* IllegalArgumentException * IllegalArgumentException
* @run main/othervm SetClientMode
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
/* /*
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
* @test * @test
* @bug 4480441 * @bug 4480441
* @summary startHandshake giving wrong message when unconnected. * @summary startHandshake giving wrong message when unconnected.
* @run main/othervm UnconnectedSocketWrongExceptions
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
* @test * @test
* @bug 4392475 * @bug 4392475
* @summary Calling setWantClientAuth(true) disables anonymous suites * @summary Calling setWantClientAuth(true) disables anonymous suites
* @run main/timeout=180 AnonCipherWithWantClientAuth * @run main/othervm/timeout=180 AnonCipherWithWantClientAuth
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -22,10 +22,13 @@ ...@@ -22,10 +22,13 @@
*/ */
/** /**
*@test * @test
*@bug 4302026 * @bug 4302026
*@run main GetPeerHost * @run main/othervm GetPeerHost
*@summary make sure the server side doesn't do DNS lookup. *
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @summary make sure the server side doesn't do DNS lookup.
*/ */
import javax.net.*; import javax.net.*;
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @summary This test tries all the different ways in which an SSL * @summary This test tries all the different ways in which an SSL
* connection can be established to exercise different SSLSocketImpl * connection can be established to exercise different SSLSocketImpl
* constructors. * constructors.
* @run main/timeout=300 SocketCreation * @run main/othervm/timeout=300 SocketCreation
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4717766 * @bug 4717766
* @summary 1.0.3 JsseX509TrustManager erroneously calls isClientTrusted() * @summary 1.0.3 JsseX509TrustManager erroneously calls isClientTrusted()
* @run main/othervm ClientServer
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @ignore JSSE supports algorithm constraints with CR 6916074, * @ignore JSSE supports algorithm constraints with CR 6916074,
* need to update this test case in JDK 7 soon * need to update this test case in JDK 7 soon
* @author Brad Wetmore * @author Brad Wetmore
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @test * @test
* @bug 6916074 * @bug 6916074
* @summary Add support for TLS 1.2 * @summary Add support for TLS 1.2
* @run main/othervm PKIXExtendedTM
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.net.*; import java.net.*;
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
* @summary support self-issued certificate * @summary support self-issued certificate
* @run main/othervm SelfIssuedCert PKIX * @run main/othervm SelfIssuedCert PKIX
* @run main/othervm SelfIssuedCert SunX509 * @run main/othervm SelfIssuedCert SunX509
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
/* /*
* @test * @test
* @bug 6916074 * @bug 6916074
* @run main/othervm -Djavax.net.debug=all SunX509ExtendedTM
* @summary Add support for TLS 1.2 * @summary Add support for TLS 1.2
* @run main/othervm SunX509ExtendedTM
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.net.*; import java.net.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 6916074 * @bug 6916074
* @summary Add support for TLS 1.2 * @summary Add support for TLS 1.2
* @run main/othervm X509ExtendedTMEnabled
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* Ensure that the SunJSSE provider enables the X509ExtendedTrustManager. * Ensure that the SunJSSE provider enables the X509ExtendedTrustManager.
*/ */
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4522550 * @bug 4522550
* @summary SSLContext TrustMananagerFactory and KeyManagerFactory * @summary SSLContext TrustMananagerFactory and KeyManagerFactory
* should throw if not init * should throw if not init
* @run main/othervm ProviderInit
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Jaya Hangal * @author Jaya Hangal
*/ */
......
/* /*
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -25,7 +25,11 @@ ...@@ -25,7 +25,11 @@
* @test * @test
* @bug 4323990 4413069 * @bug 4323990 4413069
* @summary HttpsURLConnection doesn't send Proxy-Authorization on CONNECT * @summary HttpsURLConnection doesn't send Proxy-Authorization on CONNECT
* Incorrect checking of proxy server response * Incorrect checking of proxy server response
* @run main/othervm ProxyAuthTest
*
* No way to reserve and restore java.lang.Authenticator, need to run this
* test in othervm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -77,8 +81,7 @@ public class ProxyAuthTest { ...@@ -77,8 +81,7 @@ public class ProxyAuthTest {
/* /*
* Main method to create the server and the client * Main method to create the server and the client
*/ */
public static void main(String args[]) throws Exception public static void main(String args[]) throws Exception {
{
String keyFilename = String keyFilename =
System.getProperty("test.src", "./") + "/" + pathToStores + System.getProperty("test.src", "./") + "/" + pathToStores +
"/" + keyStoreFile; "/" + keyStoreFile;
...@@ -110,10 +113,9 @@ public class ProxyAuthTest { ...@@ -110,10 +113,9 @@ public class ProxyAuthTest {
try { try {
doClientSide(); doClientSide();
} catch (Exception e) { } catch (Exception e) {
System.out.println("Client side failed: " + System.out.println("Client side failed: " + e.getMessage());
e.getMessage());
throw e; throw e;
} }
} }
private static ServerSocketFactory getServerSocketFactory private static ServerSocketFactory getServerSocketFactory
......
/* /*
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
* @bug 4328195 * @bug 4328195
* @summary Need to include the alternate subject DN for certs, * @summary Need to include the alternate subject DN for certs,
* https should check for this * https should check for this
* @run main/othervm ServerIdentityTest
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*
* @author Yingxian Wang * @author Yingxian Wang
*/ */
...@@ -136,39 +141,45 @@ public class ServerIdentityTest { ...@@ -136,39 +141,45 @@ public class ServerIdentityTest {
volatile Exception clientException = null; volatile Exception clientException = null;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
for (int i = 0; i < keyStoreFiles.length; i++) { SSLSocketFactory reservedSFactory =
String keyFilename = HttpsURLConnection.getDefaultSSLSocketFactory();
System.getProperty("test.src", ".") + "/" + pathToStores + try {
"/" + keyStoreFiles[i]; for (int i = 0; i < keyStoreFiles.length; i++) {
String trustFilename = String keyFilename =
System.getProperty("test.src", ".") + "/" + pathToStores + System.getProperty("test.src", ".") + "/" + pathToStores +
"/" + trustStoreFiles[i]; "/" + keyStoreFiles[i];
String trustFilename =
System.getProperty("test.src", ".") + "/" + pathToStores +
"/" + trustStoreFiles[i];
System.setProperty("javax.net.ssl.keyStore", keyFilename); System.setProperty("javax.net.ssl.keyStore", keyFilename);
System.setProperty("javax.net.ssl.keyStorePassword", passwd); System.setProperty("javax.net.ssl.keyStorePassword", passwd);
System.setProperty("javax.net.ssl.trustStore", trustFilename); System.setProperty("javax.net.ssl.trustStore", trustFilename);
System.setProperty("javax.net.ssl.trustStorePassword", passwd); System.setProperty("javax.net.ssl.trustStorePassword", passwd);
if (debug) if (debug)
System.setProperty("javax.net.debug", "all"); System.setProperty("javax.net.debug", "all");
SSLContext context = SSLContext.getInstance("SSL"); SSLContext context = SSLContext.getInstance("SSL");
KeyManager[] kms = new KeyManager[1]; KeyManager[] kms = new KeyManager[1];
KeyStore ks = KeyStore.getInstance("JKS"); KeyStore ks = KeyStore.getInstance("JKS");
FileInputStream fis = new FileInputStream(keyFilename); FileInputStream fis = new FileInputStream(keyFilename);
ks.load(fis, passwd.toCharArray()); ks.load(fis, passwd.toCharArray());
fis.close(); fis.close();
KeyManager km = new MyKeyManager(ks, passwd.toCharArray()); KeyManager km = new MyKeyManager(ks, passwd.toCharArray());
kms[0] = km; kms[0] = km;
context.init(kms, null, null); context.init(kms, null, null);
HttpsURLConnection.setDefaultSSLSocketFactory( HttpsURLConnection.setDefaultSSLSocketFactory(
context.getSocketFactory()); context.getSocketFactory());
/* /*
* Start the tests. * Start the tests.
*/ */
System.out.println("Testing " + keyFilename); System.out.println("Testing " + keyFilename);
new ServerIdentityTest(context, keyStoreFiles[i]); new ServerIdentityTest(context, keyStoreFiles[i]);
}
} finally {
HttpsURLConnection.setDefaultSSLSocketFactory(reservedSFactory);
} }
} }
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
* @bug 6668231 * @bug 6668231
* @summary Presence of a critical subjectAltName causes JSSE's SunX509 to * @summary Presence of a critical subjectAltName causes JSSE's SunX509 to
* fail trusted checks * fail trusted checks
* @run main/othervm CriticalSubjectAltName
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*
* @author Xuelei Fan * @author Xuelei Fan
* *
* This test depends on binary keystore, crisubn.jks and trusted.jks. Because * This test depends on binary keystore, crisubn.jks and trusted.jks. Because
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
* @test * @test
* @bug 4482187 * @bug 4482187
* @summary HttpsClient tests are failing for build 71 * @summary HttpsClient tests are failing for build 71
* @run main/othervm GetResponseCode
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*
* @author Yingxian Wang * @author Yingxian Wang
*/ */
import java.io.*; import java.io.*;
......
/* /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2011, 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
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 5070632 * @bug 5070632
* @summary Default SSLSockeFactory override createSocket() now * @summary Default SSLSockeFactory override createSocket() now
* @run main/othervm Fix5070632
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Weijun Wang * @author Weijun Wang
*/ */
...@@ -35,8 +39,13 @@ import java.security.*; ...@@ -35,8 +39,13 @@ import java.security.*;
public class Fix5070632 { public class Fix5070632 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// reserve the security properties
String reservedSFacProvider =
Security.getProperty("ssl.SocketFactory.provider");
// use a non-existing provider so that the DefaultSSLSocketFactory // use a non-existing provider so that the DefaultSSLSocketFactory
// will be used, and then test against it. // will be used, and then test against it.
Security.setProperty("ssl.SocketFactory.provider", "foo.NonExistant"); Security.setProperty("ssl.SocketFactory.provider", "foo.NonExistant");
SSLSocketFactory fac = (SSLSocketFactory)SSLSocketFactory.getDefault(); SSLSocketFactory fac = (SSLSocketFactory)SSLSocketFactory.getDefault();
try { try {
...@@ -46,8 +55,16 @@ public class Fix5070632 { ...@@ -46,8 +55,16 @@ public class Fix5070632 {
System.out.println("Throw SocketException"); System.out.println("Throw SocketException");
se.printStackTrace(); se.printStackTrace();
return; return;
} finally {
// restore the security properties
if (reservedSFacProvider == null) {
reservedSFacProvider = "";
}
Security.setProperty("ssl.SocketFactory.provider",
reservedSFacProvider);
} }
throw new Exception("should throw SocketException");
// if not caught, or other exception caught, then it's error // if not caught, or other exception caught, then it's error
throw new Exception("should throw SocketException");
} }
} }
/* /*
* Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
* @summary Need to revisit the javadocs for JSSE, especially the * @summary Need to revisit the javadocs for JSSE, especially the
* promoted classes, and HttpsURLConnection.getCipherSuite throws * promoted classes, and HttpsURLConnection.getCipherSuite throws
* NullPointerException * NullPointerException
* @run main/othervm ComURLNulls
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
...@@ -34,6 +38,7 @@ import java.net.*; ...@@ -34,6 +38,7 @@ import java.net.*;
import java.io.*; import java.io.*;
import javax.net.ssl.*; import javax.net.ssl.*;
import com.sun.net.ssl.HttpsURLConnection; import com.sun.net.ssl.HttpsURLConnection;
import com.sun.net.ssl.HostnameVerifier;
/* /*
* Tests that the com null argument changes made it in ok. * Tests that the com null argument changes made it in ok.
...@@ -42,59 +47,64 @@ import com.sun.net.ssl.HttpsURLConnection; ...@@ -42,59 +47,64 @@ import com.sun.net.ssl.HttpsURLConnection;
public class ComURLNulls { public class ComURLNulls {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
/**
* This test does not establish any connection to the specified
* URL, hence a dummy URL is used.
*/
URL foobar = new URL("https://example.com/");
System.setProperty("java.protocol.handler.pkgs", HttpsURLConnection urlc =
"com.sun.net.ssl.internal.www.protocol"); (HttpsURLConnection) foobar.openConnection();
/**
* This test does not establish any connection to the specified
* URL, hence a dummy URL is used.
*/
URL foobar = new URL("https://example.com/");
HttpsURLConnection urlc = try {
(HttpsURLConnection) foobar.openConnection(); urlc.getCipherSuite();
} catch (IllegalStateException e) {
System.out.print("Caught proper exception: ");
System.out.println(e.getMessage());
}
try { try {
urlc.getCipherSuite(); urlc.getServerCertificateChain();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try {
urlc.getServerCertificateChain();
} catch (IllegalStateException e) {
System.out.print("Caught proper exception: ");
System.out.println(e.getMessage());
}
try { try {
urlc.setDefaultHostnameVerifier(null); urlc.setDefaultHostnameVerifier(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setHostnameVerifier(null); urlc.setHostnameVerifier(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setDefaultSSLSocketFactory(null); urlc.setDefaultSSLSocketFactory(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setSSLSocketFactory(null); urlc.setSSLSocketFactory(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception"); System.out.print("Caught proper exception");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
}
System.out.println("TESTS PASSED");
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
System.out.println("TESTS PASSED");
} }
} }
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4387882 * @bug 4387882
* @summary Need to revisit the javadocs for JSSE, especially the * @summary Need to revisit the javadocs for JSSE, especially the
* promoted classes. * promoted classes.
* @run main/othervm ImplicitHandshake
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
/* /*
* Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -42,63 +42,69 @@ public class JavaxURLNulls { ...@@ -42,63 +42,69 @@ public class JavaxURLNulls {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
/** HostnameVerifier reservedHV =
* This test does not establish any connection to the specified HttpsURLConnection.getDefaultHostnameVerifier();
* URL, hence a dummy URL is used. try {
*/ /**
URL foobar = new URL("https://example.com/"); * This test does not establish any connection to the specified
* URL, hence a dummy URL is used.
*/
URL foobar = new URL("https://example.com/");
HttpsURLConnection urlc = HttpsURLConnection urlc =
(HttpsURLConnection) foobar.openConnection(); (HttpsURLConnection) foobar.openConnection();
try { try {
urlc.getCipherSuite(); urlc.getCipherSuite();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.getLocalCertificates(); urlc.getLocalCertificates();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.getServerCertificates(); urlc.getServerCertificates();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setDefaultHostnameVerifier(null); urlc.setDefaultHostnameVerifier(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setHostnameVerifier(null); urlc.setHostnameVerifier(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setDefaultSSLSocketFactory(null); urlc.setDefaultSSLSocketFactory(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
try { try {
urlc.setSSLSocketFactory(null); urlc.setSSLSocketFactory(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.print("Caught proper exception: "); System.out.print("Caught proper exception: ");
System.out.println(e.getMessage()); System.out.println(e.getMessage());
}
System.out.println("TESTS PASSED");
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
System.out.println("TESTS PASSED");
} }
} }
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4387882 * @bug 4387882
* @summary Need to revisit the javadocs for JSSE, especially the * @summary Need to revisit the javadocs for JSSE, especially the
* promoted classes. * promoted classes.
* @run main/othervm SSLSessionNulls
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
* @summary Need to revisit the javadocs for JSSE, especially the * @summary Need to revisit the javadocs for JSSE, especially the
* promoted classes. This test checks to see if the settings * promoted classes. This test checks to see if the settings
* on the server sockets get propagated to the sockets. * on the server sockets get propagated to the sockets.
* @run main/othervm SSLSocketInherit
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4329114 * @bug 4329114
* @summary Need better way of reflecting the reason when a chain is * @summary Need better way of reflecting the reason when a chain is
* rejected as untrusted. * rejected as untrusted.
* @run main/othervm CheckMyTrustedKeystore
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @ignore JSSE supports algorithm constraints with CR 6916074, * @ignore JSSE supports algorithm constraints with CR 6916074,
* need to update this test case in JDK 7 soon * need to update this test case in JDK 7 soon
* This is a serious hack job! * This is a serious hack job!
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
* Fixed 4354003: Need API to get client certificate chain * Fixed 4354003: Need API to get client certificate chain
* Fixed 4387961: HostnameVerifier needs to pass various hostnames * Fixed 4387961: HostnameVerifier needs to pass various hostnames
* Fixed 4395266: HttpsURLConnection should be made protected * Fixed 4395266: HttpsURLConnection should be made protected
* @run main/othervm HttpsURLConnectionLocalCertificateChain
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4280338 * @bug 4280338
* @summary "Unsupported SSL message version" SSLProtocolException * @summary "Unsupported SSL message version" SSLProtocolException
* w/SSL_RSA_WITH_NULL_MD5 * w/SSL_RSA_WITH_NULL_MD5
* @run main/othervm JSSERenegotiate
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Ram Marti * @author Ram Marti
* @author Brad Wetmore * @author Brad Wetmore
......
/* /*
* Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
* 4396290: Need a way to pass algorithm specific parameters to TM's and KM's * 4396290: Need a way to pass algorithm specific parameters to TM's and KM's
* 4395286: The property for setting the default * 4395286: The property for setting the default
* KeyManagerFactory/TrustManagerFactory algorithms needs real name * KeyManagerFactory/TrustManagerFactory algorithms needs real name
* @run main/othervm KeyManagerTrustManager
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
...@@ -77,17 +81,40 @@ public class KeyManagerTrustManager implements X509KeyManager { ...@@ -77,17 +81,40 @@ public class KeyManagerTrustManager implements X509KeyManager {
String kmfAlg = null; String kmfAlg = null;
String tmfAlg = null; String tmfAlg = null;
Security.setProperty("ssl.KeyManagerFactory.algorithm", "hello"); // reserve the security properties
Security.setProperty("ssl.TrustManagerFactory.algorithm", "goodbye"); String reservedKMFacAlg =
Security.getProperty("ssl.KeyManagerFactory.algorithm");
String reservedTMFacAlg =
Security.getProperty("ssl.TrustManagerFactory.algorithm");
kmfAlg = KeyManagerFactory.getDefaultAlgorithm(); try {
tmfAlg = TrustManagerFactory.getDefaultAlgorithm(); Security.setProperty("ssl.KeyManagerFactory.algorithm", "hello");
Security.setProperty("ssl.TrustManagerFactory.algorithm",
"goodbye");
if (!kmfAlg.equals("hello")) { kmfAlg = KeyManagerFactory.getDefaultAlgorithm();
throw new Exception("ssl.KeyManagerFactory.algorithm not set"); tmfAlg = TrustManagerFactory.getDefaultAlgorithm();
}
if (!tmfAlg.equals("goodbye")) { if (!kmfAlg.equals("hello")) {
throw new Exception("ssl.TrustManagerFactory.algorithm not set"); throw new Exception("ssl.KeyManagerFactory.algorithm not set");
}
if (!tmfAlg.equals("goodbye")) {
throw new Exception(
"ssl.TrustManagerFactory.algorithm not set");
}
} finally {
// restore the security properties
if (reservedKMFacAlg == null) {
reservedKMFacAlg = "";
}
if (reservedTMFacAlg == null) {
reservedTMFacAlg = "";
}
Security.setProperty("ssl.KeyManagerFactory.algorithm",
reservedKMFacAlg);
Security.setProperty("ssl.TrustManagerFactory.algorithm",
reservedTMFacAlg);
} }
} }
} }
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4473210 * @bug 4473210
* @summary SSLSessionContext should be accessible from SSLContext * @summary SSLSessionContext should be accessible from SSLContext
* @run main/othervm SSLCtxAccessToSessCtx
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 6388456 * @bug 6388456
* @summary Need adjustable TLS max record size for interoperability * @summary Need adjustable TLS max record size for interoperability
* with non-compliant stacks * with non-compliant stacks
* @run main/othervm AcceptLargeFragments
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* Check the system property "jsse.SSLEngine.acceptLargeFragments" * Check the system property "jsse.SSLEngine.acceptLargeFragments"
* *
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4981697 * @bug 4981697
* @summary Rework the X509KeyManager to avoid incompatibility issues * @summary Rework the X509KeyManager to avoid incompatibility issues
* @run main/othervm ExtendedKeySocket
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad R. Wetmore * @author Brad R. Wetmore
*/ */
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
* @bug 6388456 * @bug 6388456
* @summary Need adjustable TLS max record size for interoperability * @summary Need adjustable TLS max record size for interoperability
* with non-compliant * with non-compliant
* @run main/othervm LargePacket
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4495742 * @bug 4495742
* @summary Demonstrate SSLEngine switch from no client auth to client auth. * @summary Demonstrate SSLEngine switch from no client auth to client auth.
* @run main/othervm NoAuthClientAuth
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Brad R. Wetmore * @author Brad R. Wetmore
*/ */
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4366807 * @bug 4366807
* @summary Need new APIs to get/set session timeout and session cache size. * @summary Need new APIs to get/set session timeout and session cache size.
* @run main/othervm SessionCacheSizeTests
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4366807 * @bug 4366807
* @summary Need new APIs to get/set session timeout and session cache size. * @summary Need new APIs to get/set session timeout and session cache size.
* @run main/othervm SessionTimeOutTests
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -207,7 +211,7 @@ public class SessionTimeOutTests { ...@@ -207,7 +211,7 @@ public class SessionTimeOutTests {
timeout = sessCtx.getSessionTimeout(); timeout = sessCtx.getSessionTimeout();
System.out.println("timeout is changed to: " + timeout); System.out.println("timeout is changed to: " + timeout);
System.out.println(); System.out.println();
} }
} }
// check the ids returned by the enumerator // check the ids returned by the enumerator
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
* session * session
* 4701722 protocol mismatch exceptions should be consistent between * 4701722 protocol mismatch exceptions should be consistent between
* SSLv3 and TLSv1 * SSLv3 and TLSv1
* @run main/othervm testEnabledProtocols
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Ram Marti * @author Ram Marti
*/ */
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2011, 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
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 6449579 * @bug 6449579
* @summary DefaultSSLServerSocketFactory does not override createServerSocket() * @summary DefaultSSLServerSocketFactory does not override createServerSocket()
* @run main/othervm DefaultSSLServSocketFac
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.security.Security; import java.security.Security;
import javax.net.ServerSocketFactory; import javax.net.ServerSocketFactory;
...@@ -33,6 +37,10 @@ import javax.net.ssl.SSLServerSocketFactory; ...@@ -33,6 +37,10 @@ import javax.net.ssl.SSLServerSocketFactory;
public class DefaultSSLServSocketFac { public class DefaultSSLServSocketFac {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// reserve the security properties
String reservedSSFacProvider =
Security.getProperty("ssl.ServerSocketFactory.provider");
try { try {
Security.setProperty("ssl.ServerSocketFactory.provider", "oops"); Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
ServerSocketFactory ssocketFactory = ServerSocketFactory ssocketFactory =
...@@ -44,6 +52,13 @@ public class DefaultSSLServSocketFac { ...@@ -44,6 +52,13 @@ public class DefaultSSLServSocketFac {
throw e; throw e;
} }
// get the expected exception // get the expected exception
} finally {
// restore the security properties
if (reservedSSFacProvider == null) {
reservedSSFacProvider = "";
}
Security.setProperty("ssl.ServerSocketFactory.provider",
reservedSSFacProvider);
} }
} }
} }
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @test * @test
* @bug 4873188 * @bug 4873188
* @summary Support TLS 1.1 * @summary Support TLS 1.1
* @run main/othervm -Djavax.net.debug=all EmptyCertificateAuthorities * @run main/othervm EmptyCertificateAuthorities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @test * @test
* @bug 4873188 * @bug 4873188
* @summary Support TLS 1.1 * @summary Support TLS 1.1
* @run main/othervm -Djavax.net.debug=all ExportableBlockCipher * @run main/othervm ExportableBlockCipher
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @test * @test
* @bug 4873188 * @bug 4873188
* @summary Support TLS 1.1 * @summary Support TLS 1.1
* @run main/othervm -Djavax.net.debug=all ExportableStreamCipher * @run main/othervm ExportableStreamCipher
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @test * @test
* @bug 4873188 * @bug 4873188
* @summary Support TLS 1.1 * @summary Support TLS 1.1
* @run main/othervm -Djavax.net.debug=all GenericBlockCipher * @run main/othervm GenericBlockCipher
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
* @test * @test
* @bug 4873188 * @bug 4873188
* @summary Support TLS 1.1 * @summary Support TLS 1.1
* @run main/othervm -Djavax.net.debug=all GenericStreamCipher * @run main/othervm GenericStreamCipher
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
...@@ -64,8 +64,8 @@ public class CheckSSLContextExport extends Provider { ...@@ -64,8 +64,8 @@ public class CheckSSLContextExport extends Provider {
default: default:
throw new Exception("Internal Test Error!"); throw new Exception("Internal Test Error!");
} }
System.out.println("Testing with " + (standardCiphers ? "standard" : "custom") + System.out.println("Testing with " +
" cipher suites"); (standardCiphers ? "standard" : "custom") + " cipher suites");
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
String clsName = null; String clsName = null;
try { try {
...@@ -107,11 +107,16 @@ public class CheckSSLContextExport extends Provider { ...@@ -107,11 +107,16 @@ public class CheckSSLContextExport extends Provider {
public static void main(String[] argv) throws Exception { public static void main(String[] argv) throws Exception {
String protocols[] = { "SSL", "TLS" }; String protocols[] = { "SSL", "TLS" };
Security.insertProviderAt(new CheckSSLContextExport(protocols), 1); Provider extraProvider = new CheckSSLContextExport(protocols);
for (int i = 0; i < protocols.length; i++) { Security.insertProviderAt(extraProvider, 1);
System.out.println("Testing " + protocols[i] + "'s SSLContext"); try {
test(protocols[i]); for (int i = 0; i < protocols.length; i++) {
System.out.println("Testing " + protocols[i] + "'s SSLContext");
test(protocols[i]);
}
System.out.println("Test Passed");
} finally {
Security.removeProvider(extraProvider.getName());
} }
System.out.println("Test Passed");
} }
} }
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4635454 6208022 * @bug 4635454 6208022
* @summary Check pluggability of SSLSocketFactory and * @summary Check pluggability of SSLSocketFactory and
* SSLServerSocketFactory classes. * SSLServerSocketFactory classes.
* @run main/othervm CheckSockFacExport1
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.util.*; import java.util.*;
...@@ -37,36 +41,57 @@ import javax.net.ssl.*; ...@@ -37,36 +41,57 @@ import javax.net.ssl.*;
public class CheckSockFacExport1 { public class CheckSockFacExport1 {
public static void main(String argv[]) throws Exception { public static void main(String argv[]) throws Exception {
Security.setProperty("ssl.SocketFactory.provider", // reserve the security properties
"MySSLSocketFacImpl"); String reservedSFacAlg =
MySSLSocketFacImpl.useCustomCipherSuites(); Security.getProperty("ssl.SocketFactory.provider");
Security.setProperty("ssl.ServerSocketFactory.provider", String reservedSSFacAlg =
"MySSLServerSocketFacImpl"); Security.getProperty("ssl.ServerSocketFactory.provider");
MySSLServerSocketFacImpl.useCustomCipherSuites();
try {
Security.setProperty("ssl.SocketFactory.provider",
"MySSLSocketFacImpl");
MySSLSocketFacImpl.useCustomCipherSuites();
Security.setProperty("ssl.ServerSocketFactory.provider",
"MySSLServerSocketFacImpl");
MySSLServerSocketFacImpl.useCustomCipherSuites();
String[] supportedCS = null; String[] supportedCS = null;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
switch (i) { switch (i) {
case 0: case 0:
System.out.println("Testing SSLSocketFactory:"); System.out.println("Testing SSLSocketFactory:");
SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory sf = (SSLSocketFactory)
SSLSocketFactory.getDefault(); SSLSocketFactory.getDefault();
supportedCS = sf.getSupportedCipherSuites(); supportedCS = sf.getSupportedCipherSuites();
break; break;
case 1: case 1:
System.out.println("Testing SSLServerSocketFactory:"); System.out.println("Testing SSLServerSocketFactory:");
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory ssf = (SSLServerSocketFactory)
SSLServerSocketFactory.getDefault(); SSLServerSocketFactory.getDefault();
supportedCS = ssf.getSupportedCipherSuites(); supportedCS = ssf.getSupportedCipherSuites();
break; break;
default: default:
throw new Exception("Internal Test Error"); throw new Exception("Internal Test Error");
}
System.out.println(Arrays.asList(supportedCS));
if (supportedCS.length == 0) {
throw new Exception("supported ciphersuites are empty");
}
} }
System.out.println(Arrays.asList(supportedCS)); System.out.println("Test Passed");
if (supportedCS.length == 0) { } finally {
throw new Exception("supported ciphersuites are empty"); // restore the security properties
if (reservedSFacAlg == null) {
reservedSFacAlg = "";
}
if (reservedSSFacAlg == null) {
reservedSSFacAlg = "";
} }
Security.setProperty("ssl.SocketFactory.provider",
reservedSFacAlg);
Security.setProperty("ssl.ServerSocketFactory.provider",
reservedSSFacAlg);
} }
System.out.println("Test Passed");
} }
} }
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -25,7 +25,11 @@ ...@@ -25,7 +25,11 @@
* @test * @test
* @bug 4635454 * @bug 4635454
* @summary Check pluggability of SSLSocketFactory and * @summary Check pluggability of SSLSocketFactory and
* SSLServerSocketFactory classes. * SSLServerSocketFactory classes.
* @run main/othervm CheckSockFacExport2
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.security.*; import java.security.*;
import java.net.*; import java.net.*;
...@@ -34,38 +38,59 @@ import javax.net.ssl.*; ...@@ -34,38 +38,59 @@ import javax.net.ssl.*;
public class CheckSockFacExport2 { public class CheckSockFacExport2 {
public static void main(String argv[]) throws Exception { public static void main(String argv[]) throws Exception {
Security.setProperty("ssl.SocketFactory.provider", // reserve the security properties
"MySSLSocketFacImpl"); String reservedSFacAlg =
MySSLSocketFacImpl.useStandardCipherSuites(); Security.getProperty("ssl.SocketFactory.provider");
Security.setProperty("ssl.ServerSocketFactory.provider", String reservedSSFacAlg =
"MySSLServerSocketFacImpl"); Security.getProperty("ssl.ServerSocketFactory.provider");
MySSLServerSocketFacImpl.useStandardCipherSuites();
try {
Security.setProperty("ssl.SocketFactory.provider",
"MySSLSocketFacImpl");
MySSLSocketFacImpl.useStandardCipherSuites();
Security.setProperty("ssl.ServerSocketFactory.provider",
"MySSLServerSocketFacImpl");
MySSLServerSocketFacImpl.useStandardCipherSuites();
boolean result = false; boolean result = false;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
switch (i) { switch (i) {
case 0: case 0:
System.out.println("Testing SSLSocketFactory:"); System.out.println("Testing SSLSocketFactory:");
SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory sf = (SSLSocketFactory)
SSLSocketFactory.getDefault(); SSLSocketFactory.getDefault();
result = (sf instanceof MySSLSocketFacImpl); result = (sf instanceof MySSLSocketFacImpl);
break; break;
case 1: case 1:
System.out.println("Testing SSLServerSocketFactory:"); System.out.println("Testing SSLServerSocketFactory:");
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory ssf = (SSLServerSocketFactory)
SSLServerSocketFactory.getDefault(); SSLServerSocketFactory.getDefault();
result = (ssf instanceof MySSLServerSocketFacImpl); result = (ssf instanceof MySSLServerSocketFacImpl);
break; break;
default: default:
throw new Exception("Internal Test Error"); throw new Exception("Internal Test Error");
}
if (result) {
System.out.println("...accepted valid SFs");
} else {
throw new Exception("...wrong SF is used");
}
} }
if (result) { System.out.println("Test Passed");
System.out.println("...accepted valid SFs"); } finally {
} else { // restore the security properties
throw new Exception("...wrong SF is used"); if (reservedSFacAlg == null) {
reservedSFacAlg = "";
}
if (reservedSSFacAlg == null) {
reservedSSFacAlg = "";
} }
Security.setProperty("ssl.SocketFactory.provider",
reservedSFacAlg);
Security.setProperty("ssl.ServerSocketFactory.provider",
reservedSSFacAlg);
} }
System.out.println("Test Passed");
} }
} }
/* /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2011, 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
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
* @bug 5026745 * @bug 5026745
* @library ../../httpstest/ * @library ../../httpstest/
* @run main/othervm Test * @run main/othervm Test
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @summary Cannot flush output stream when writing to an HttpUrlConnection * @summary Cannot flush output stream when writing to an HttpUrlConnection
*/ */
...@@ -283,31 +286,37 @@ public class Test implements HttpCallback { ...@@ -283,31 +286,37 @@ public class Test implements HttpCallback {
System.getProperty("test.src", "./") + "/" + pathToStores + System.getProperty("test.src", "./") + "/" + pathToStores +
"/" + trustStoreFile; "/" + trustStoreFile;
System.setProperty("javax.net.ssl.keyStore", keyFilename); HostnameVerifier reservedHV =
System.setProperty("javax.net.ssl.keyStorePassword", passwd); HttpsURLConnection.getDefaultHostnameVerifier();
System.setProperty("javax.net.ssl.trustStore", trustFilename);
System.setProperty("javax.net.ssl.trustStorePassword", passwd);
HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
try { try {
server = new HttpServer (new Test(), 1, 10, 0); System.setProperty("javax.net.ssl.keyStore", keyFilename);
System.out.println ("Server started: listening on port: " + server.getLocalPort()); System.setProperty("javax.net.ssl.keyStorePassword", passwd);
// the test server doesn't support keep-alive yet System.setProperty("javax.net.ssl.trustStore", trustFilename);
// test1("http://localhost:"+server.getLocalPort()+"/d0"); System.setProperty("javax.net.ssl.trustStorePassword", passwd);
test1("https://localhost:"+server.getLocalPort()+"/d01"); HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
test3("https://localhost:"+server.getLocalPort()+"/d3");
test4("https://localhost:"+server.getLocalPort()+"/d4"); try {
test5("https://localhost:"+server.getLocalPort()+"/d5"); server = new HttpServer (new Test(), 1, 10, 0);
test6("https://localhost:"+server.getLocalPort()+"/d6"); System.out.println ("Server started: listening on port: " + server.getLocalPort());
test7("https://localhost:"+server.getLocalPort()+"/d7"); // the test server doesn't support keep-alive yet
test8("https://localhost:"+server.getLocalPort()+"/d8"); // test1("http://localhost:"+server.getLocalPort()+"/d0");
} catch (Exception e) { test1("https://localhost:"+server.getLocalPort()+"/d01");
if (server != null) { test3("https://localhost:"+server.getLocalPort()+"/d3");
server.terminate(); test4("https://localhost:"+server.getLocalPort()+"/d4");
test5("https://localhost:"+server.getLocalPort()+"/d5");
test6("https://localhost:"+server.getLocalPort()+"/d6");
test7("https://localhost:"+server.getLocalPort()+"/d7");
test8("https://localhost:"+server.getLocalPort()+"/d8");
} catch (Exception e) {
if (server != null) {
server.terminate();
}
throw e;
} }
throw e; server.terminate();
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
server.terminate();
} }
static class NameVerifier implements HostnameVerifier { static class NameVerifier implements HostnameVerifier {
......
/* /*
* Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, 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
...@@ -26,9 +26,12 @@ ...@@ -26,9 +26,12 @@
* @bug 6216082 * @bug 6216082
* @library ../../../httpstest/ * @library ../../../httpstest/
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction TunnelProxy * @build HttpCallback HttpServer ClosedChannelList HttpTransaction TunnelProxy
* @run main/othervm B6216082
* @summary Redirect problem with HttpsURLConnection using a proxy * @summary Redirect problem with HttpsURLConnection using a proxy
*/ * @run main/othervm B6216082
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
...@@ -46,20 +49,27 @@ public class B6216082 { ...@@ -46,20 +49,27 @@ public class B6216082 {
static InetAddress firstNonLoAddress = null; static InetAddress firstNonLoAddress = null;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// XXX workaround for CNFE HostnameVerifier reservedHV =
Class.forName("java.nio.channels.ClosedByInterruptException"); HttpsURLConnection.getDefaultHostnameVerifier();
setupEnv(); try {
// XXX workaround for CNFE
Class.forName("java.nio.channels.ClosedByInterruptException");
setupEnv();
startHttpServer(); startHttpServer();
// https.proxyPort can only be set after the TunnelProxy has been // https.proxyPort can only be set after the TunnelProxy has been
// created as it will use an ephemeral port. // created as it will use an ephemeral port.
System.setProperty( "https.proxyPort", (new Integer(proxy.getLocalPort())).toString() ); System.setProperty("https.proxyPort",
(new Integer(proxy.getLocalPort())).toString() );
makeHttpCall(); makeHttpCall();
if (httpTrans.hasBadRequest) { if (httpTrans.hasBadRequest) {
throw new RuntimeException("Test failed : bad http request"); throw new RuntimeException("Test failed : bad http request");
}
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
} }
......
/* /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2011, 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
...@@ -26,7 +26,10 @@ ...@@ -26,7 +26,10 @@
* @bug 6618387 * @bug 6618387
* @summary SSL client sessions do not close cleanly. A TCP reset occurs * @summary SSL client sessions do not close cleanly. A TCP reset occurs
* instead of a close_notify alert. * instead of a close_notify alert.
* @run main/othervm -Djavax.net.debug=ssl CloseKeepAliveCached * @run main/othervm CloseKeepAliveCached
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @ignore * @ignore
* After run the test manually, at the end of the debug output, * After run the test manually, at the end of the debug output,
...@@ -140,13 +143,15 @@ public class CloseKeepAliveCached { ...@@ -140,13 +143,15 @@ public class CloseKeepAliveCached {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (!serverReady) { while (!serverReady) {
Thread.sleep(50); Thread.sleep(50);
} }
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try { try {
HttpsURLConnection http = null; HttpsURLConnection http = null;
...@@ -180,6 +185,8 @@ public class CloseKeepAliveCached { ...@@ -180,6 +185,8 @@ public class CloseKeepAliveCached {
if (sslServerSocket != null) if (sslServerSocket != null)
sslServerSocket.close(); sslServerSocket.close();
throw ioex; throw ioex;
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
} }
......
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
*/ */
/* @test /* @test
* @summary Unit test for java.net.CookieHandler
* @bug 4696506 4942650 * @bug 4696506 4942650
* @summary Unit test for java.net.CookieHandler
* @run main/othervm CookieHandlerTest
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Yingxian Wang * @author Yingxian Wang
*/ */
...@@ -182,26 +186,34 @@ public class CookieHandlerTest { ...@@ -182,26 +186,34 @@ public class CookieHandlerTest {
System.getProperty("test.src", "./") + "/" + pathToStores + System.getProperty("test.src", "./") + "/" + pathToStores +
"/" + trustStoreFile; "/" + trustStoreFile;
System.setProperty("javax.net.ssl.keyStore", keyFilename); CookieHandler reservedCookieHandler = CookieHandler.getDefault();
System.setProperty("javax.net.ssl.keyStorePassword", passwd); HostnameVerifier reservedHV =
System.setProperty("javax.net.ssl.trustStore", trustFilename); HttpsURLConnection.getDefaultHostnameVerifier();
System.setProperty("javax.net.ssl.trustStorePassword", passwd); try {
System.setProperty("javax.net.ssl.keyStore", keyFilename);
if (debug) System.setProperty("javax.net.ssl.keyStorePassword", passwd);
System.setProperty("javax.net.debug", "all"); System.setProperty("javax.net.ssl.trustStore", trustFilename);
System.setProperty("javax.net.ssl.trustStorePassword", passwd);
/*
* Start the tests. if (debug)
*/ System.setProperty("javax.net.debug", "all");
cookies = new HashMap<String, String>();
cookies.put("Cookie", /*
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\""); * Start the tests.
cookies.put("Set-Cookie2", */
"$Version=\"1\"; Part_Number=\"Riding_Rocket_0023\"; " + cookies = new HashMap<String, String>();
"$Path=\"/acme/ammo\"; Part_Number=\"Rocket_Launcher_0001\"; "+ cookies.put("Cookie",
"$Path=\"/acme\""); "$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"");
CookieHandler.setDefault(new MyCookieHandler()); cookies.put("Set-Cookie2",
new CookieHandlerTest(); "$Version=\"1\"; Part_Number=\"Riding_Rocket_0023\"; " +
"$Path=\"/acme/ammo\"; Part_Number=\"Rocket_Launcher_0001\"; "+
"$Path=\"/acme\"");
CookieHandler.setDefault(new MyCookieHandler());
new CookieHandlerTest();
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
CookieHandler.setDefault(reservedCookieHandler);
}
} }
Thread clientThread = null; Thread clientThread = null;
......
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
*/ */
/* @test /* @test
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @bug 6766775 * @bug 6766775
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @run main/othervm DNSIdentities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
...@@ -691,34 +695,39 @@ public class DNSIdentities { ...@@ -691,34 +695,39 @@ public class DNSIdentities {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr, SSLContext reservedSSLContext = SSLContext.getDefault();
clientModulus, clientPrivateExponent, passphrase); try {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr,
clientModulus, clientPrivateExponent, passphrase);
SSLContext.setDefault(context); SSLContext.setDefault(context);
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (!serverReady) { while (!serverReady) {
Thread.sleep(50); Thread.sleep(50);
} }
HttpsURLConnection http = null; HttpsURLConnection http = null;
/* establish http connection to server */ /* establish http connection to server */
URL url = new URL("https://localhost:" + serverPort+"/"); URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString()); System.out.println("url is "+url.toString());
try { try {
http = (HttpsURLConnection)url.openConnection(); http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode(); int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode); System.out.println("respCode = "+respCode);
} finally { } finally {
if (http != null) { if (http != null) {
http.disconnect(); http.disconnect();
}
closeReady = true;
} }
closeReady = true; } finally {
SSLContext.setDefault(reservedSSLContext);
} }
} }
......
...@@ -24,7 +24,12 @@ ...@@ -24,7 +24,12 @@
/** /**
* @test * @test
* @bug 6771432 * @bug 6771432
* @summary createSocket() - smpatch fails using 1.6.0_10 because of "Unconnected sockets not implemented" * @summary createSocket() - smpatch fails using 1.6.0_10 because of
* "Unconnected sockets not implemented"
* @run main/othervm HttpsCreateSockTest
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import javax.net.SocketFactory; import javax.net.SocketFactory;
......
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4423074 * @bug 4423074
* @summary Need to rebase all the duplicated classes from Merlin. * @summary Need to rebase all the duplicated classes from Merlin.
* This test will check out http POST * This test will check out http POST
* @run main/othervm HttpsPost
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -140,34 +144,38 @@ public class HttpsPost { ...@@ -140,34 +144,38 @@ public class HttpsPost {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
/*
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
/* // Send HTTP POST request to server
* Wait for server to get started. URL url = new URL("https://localhost:"+serverPort);
*/
while (!serverReady) {
Thread.sleep(50);
}
// Send HTTP POST request to server
URL url = new URL("https://localhost:"+serverPort);
HttpsURLConnection.setDefaultHostnameVerifier( HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
new NameVerifier()); HttpsURLConnection http = (HttpsURLConnection)url.openConnection();
HttpsURLConnection http = (HttpsURLConnection)url.openConnection(); http.setDoOutput(true);
http.setDoOutput(true);
http.setRequestMethod("POST"); http.setRequestMethod("POST");
PrintStream ps = new PrintStream(http.getOutputStream()); PrintStream ps = new PrintStream(http.getOutputStream());
try { try {
ps.println(postMsg); ps.println(postMsg);
ps.flush(); ps.flush();
if (http.getResponseCode() != 200) { if (http.getResponseCode() != 200) {
throw new RuntimeException("test Failed"); throw new RuntimeException("test Failed");
}
} finally {
ps.close();
http.disconnect();
closeReady = true;
} }
} finally { } finally {
ps.close(); HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
http.disconnect();
closeReady = true;
} }
} }
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
* @test * @test
* @bug 6670868 * @bug 6670868
* @summary StackOverFlow with bad authenticated Proxy tunnels * @summary StackOverFlow with bad authenticated Proxy tunnels
* @run main/othervm HttpsProxyStackOverflow
*
* No way to reserve default Authenticator, need to run in othervm mode.
*/ */
import java.io.IOException; import java.io.IOException;
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
* @bug 6614957 * @bug 6614957
* @summary HttpsURLConnection not using the set SSLSocketFactory for creating all its Sockets * @summary HttpsURLConnection not using the set SSLSocketFactory for creating all its Sockets
* @run main/othervm HttpsSocketFacTest * @run main/othervm HttpsSocketFacTest
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import javax.net.SocketFactory; import javax.net.SocketFactory;
......
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2011, 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
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
*/ */
/* @test /* @test
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @bug 6766775 * @bug 6766775
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @run main/othervm IPAddressDNSIdentities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
...@@ -691,43 +695,48 @@ public class IPAddressDNSIdentities { ...@@ -691,43 +695,48 @@ public class IPAddressDNSIdentities {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr, SSLContext reservedSSLContext = SSLContext.getDefault();
clientModulus, clientPrivateExponent, passphrase); try {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr,
SSLContext.setDefault(context); clientModulus, clientPrivateExponent, passphrase);
/*
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
HttpsURLConnection http = null; SSLContext.setDefault(context);
/* establish http connection to server */ /*
URL url = new URL("https://127.0.0.1:" + serverPort+"/"); * Wait for server to get started.
System.out.println("url is "+url.toString()); */
while (!serverReady) {
Thread.sleep(50);
}
try { HttpsURLConnection http = null;
http = (HttpsURLConnection)url.openConnection();
/* establish http connection to server */
int respCode = http.getResponseCode(); URL url = new URL("https://127.0.0.1:" + serverPort+"/");
System.out.println("respCode = " + respCode); System.out.println("url is "+url.toString());
throw new Exception("Unexpectly found subject alternative name " + try {
"matching IP address"); http = (HttpsURLConnection)url.openConnection();
} catch (SSLHandshakeException sslhe) {
// no subject alternative names matching IP address 127.0.0.1 found int respCode = http.getResponseCode();
// that's the expected exception, ignore it. System.out.println("respCode = " + respCode);
} catch (IOException ioe) {
// HttpsClient may throw IOE during checking URL spoofing, throw new Exception("Unexpectly found " +
// that's the expected exception, ignore it. "subject alternative name matching IP address");
} finally { } catch (SSLHandshakeException sslhe) {
if (http != null) { // no subject alternative names matching IP address 127.0.0.1
http.disconnect(); // found that's the expected exception, ignore it.
} catch (IOException ioe) {
// HttpsClient may throw IOE during checking URL spoofing,
// that's the expected exception, ignore it.
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
} }
closeReady = true; } finally {
SSLContext.setDefault(reservedSSLContext);
} }
} }
......
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2011, 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
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
/* @test /* @test
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @bug 6766775 * @bug 6766775
* @run main/othervm IPAddressIPIdentities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
...@@ -692,34 +696,39 @@ public class IPAddressIPIdentities { ...@@ -692,34 +696,39 @@ public class IPAddressIPIdentities {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr, SSLContext reservedSSLContext = SSLContext.getDefault();
clientModulus, clientPrivateExponent, passphrase); try {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr,
clientModulus, clientPrivateExponent, passphrase);
SSLContext.setDefault(context); SSLContext.setDefault(context);
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (!serverReady) { while (!serverReady) {
Thread.sleep(50); Thread.sleep(50);
} }
HttpsURLConnection http = null; HttpsURLConnection http = null;
/* establish http connection to server */ /* establish http connection to server */
URL url = new URL("https://127.0.0.1:" + serverPort+"/"); URL url = new URL("https://127.0.0.1:" + serverPort+"/");
System.out.println("url is "+url.toString()); System.out.println("url is "+url.toString());
try { try {
http = (HttpsURLConnection)url.openConnection(); http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode(); int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode); System.out.println("respCode = "+respCode);
} finally { } finally {
if (http != null) { if (http != null) {
http.disconnect(); http.disconnect();
}
closeReady = true;
} }
closeReady = true; } finally {
SSLContext.setDefault(reservedSSLContext);
} }
} }
......
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2011, 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
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
/* @test /* @test
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @bug 6766775 * @bug 6766775
* @run main/othervm IPIdentities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
...@@ -692,34 +696,38 @@ public class IPIdentities { ...@@ -692,34 +696,38 @@ public class IPIdentities {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr, SSLContext reservedSSLContext = SSLContext.getDefault();
clientModulus, clientPrivateExponent, passphrase); try {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr,
SSLContext.setDefault(context); clientModulus, clientPrivateExponent, passphrase);
SSLContext.setDefault(context);
/*
* Wait for server to get started. /*
*/ * Wait for server to get started.
while (!serverReady) { */
Thread.sleep(50); while (!serverReady) {
} Thread.sleep(50);
}
HttpsURLConnection http = null; HttpsURLConnection http = null;
/* establish http connection to server */ /* establish http connection to server */
URL url = new URL("https://localhost:" + serverPort+"/"); URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString()); System.out.println("url is "+url.toString());
try { try {
http = (HttpsURLConnection)url.openConnection(); http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode(); int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode); System.out.println("respCode = "+respCode);
} finally { } finally {
if (http != null) { if (http != null) {
http.disconnect(); http.disconnect();
}
closeReady = true;
} }
closeReady = true; } finally {
SSLContext.setDefault(reservedSSLContext);
} }
} }
......
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2011, 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
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
*/ */
/* @test /* @test
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @bug 6766775 * @bug 6766775
* @summary X509 certificate hostname checking is broken in JDK1.6.0_10
* @run main/othervm Identities
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Xuelei Fan * @author Xuelei Fan
*/ */
...@@ -691,34 +695,39 @@ public class Identities { ...@@ -691,34 +695,39 @@ public class Identities {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr, SSLContext reservedSSLContext = SSLContext.getDefault();
clientModulus, clientPrivateExponent, passphrase); try {
SSLContext context = getSSLContext(trusedCertStr, clientCertStr,
clientModulus, clientPrivateExponent, passphrase);
SSLContext.setDefault(context); SSLContext.setDefault(context);
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (!serverReady) { while (!serverReady) {
Thread.sleep(50); Thread.sleep(50);
} }
HttpsURLConnection http = null; HttpsURLConnection http = null;
/* establish http connection to server */ /* establish http connection to server */
URL url = new URL("https://localhost:" + serverPort+"/"); URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString()); System.out.println("url is "+url.toString());
try { try {
http = (HttpsURLConnection)url.openConnection(); http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode(); int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode); System.out.println("respCode = "+respCode);
} finally { } finally {
if (http != null) { if (http != null) {
http.disconnect(); http.disconnect();
}
closeReady = true;
} }
closeReady = true; } finally {
SSLContext.setDefault(reservedSSLContext);
} }
} }
......
/* /*
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -147,44 +147,50 @@ public class PostThruProxy { ...@@ -147,44 +147,50 @@ public class PostThruProxy {
static String postMsg = "Testing HTTP post on a https server"; static String postMsg = "Testing HTTP post on a https server";
static void doClientSide(String hostname) throws Exception { static void doClientSide(String hostname) throws Exception {
/* HostnameVerifier reservedHV =
* setup up a proxy HttpsURLConnection.getDefaultHostnameVerifier();
*/
setupProxy();
/*
* we want to avoid URLspoofCheck failures in cases where the cert
* DN name does not match the hostname in the URL.
*/
HttpsURLConnection.setDefaultHostnameVerifier(
new NameVerifier());
URL url = new URL("https://" + hostname+ ":" + serverPort);
HttpsURLConnection https = (HttpsURLConnection)url.openConnection();
https.setDoOutput(true);
https.setRequestMethod("POST");
PrintStream ps = null;
try { try {
ps = new PrintStream(https.getOutputStream()); /*
ps.println(postMsg); * setup up a proxy
ps.flush(); */
if (https.getResponseCode() != 200) { setupProxy();
throw new RuntimeException("test Failed");
} /*
ps.close(); * we want to avoid URLspoofCheck failures in cases where the cert
* DN name does not match the hostname in the URL.
// clear the pipe */
BufferedReader in = new BufferedReader( HttpsURLConnection.setDefaultHostnameVerifier(
new InputStreamReader( new NameVerifier());
https.getInputStream())); URL url = new URL("https://" + hostname+ ":" + serverPort);
String inputLine;
while ((inputLine = in.readLine()) != null) HttpsURLConnection https = (HttpsURLConnection)url.openConnection();
System.out.println("Client received: " + inputLine); https.setDoOutput(true);
in.close(); https.setRequestMethod("POST");
} catch (SSLException e) { PrintStream ps = null;
if (ps != null) try {
ps.close(); ps = new PrintStream(https.getOutputStream());
throw e; ps.println(postMsg);
ps.flush();
if (https.getResponseCode() != 200) {
throw new RuntimeException("test Failed");
}
ps.close();
// clear the pipe
BufferedReader in = new BufferedReader(
new InputStreamReader(
https.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println("Client received: " + inputLine);
in.close();
} catch (SSLException e) {
if (ps != null)
ps.close();
throw e;
}
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -24,7 +24,13 @@ ...@@ -24,7 +24,13 @@
/* /*
* @test * @test
* @bug 4811482 4700777 4905410 * @bug 4811482 4700777 4905410
* @summary sun.net.client.defaultConnectTimeout should work with HttpsURLConnection; HTTP client: Connect and read timeouts; Https needs to support new tiger features that went into http * @summary sun.net.client.defaultConnectTimeout should work with
* HttpsURLConnection; HTTP client: Connect and read timeouts;
* Https needs to support new tiger features that went into http
* @run main/othervm ReadTimeout
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -143,44 +149,48 @@ public class ReadTimeout { ...@@ -143,44 +149,48 @@ public class ReadTimeout {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
HostnameVerifier reservedHV =
/* HttpsURLConnection.getDefaultHostnameVerifier();
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
HttpsURLConnection http = null;
try { try {
URL url = new URL("https://localhost:"+serverPort); /*
* Wait for server to get started.
// set read timeout through system property */
System.setProperty("sun.net.client.defaultReadTimeout", "2000"); while (!serverReady) {
HttpsURLConnection.setDefaultHostnameVerifier( Thread.sleep(50);
new NameVerifier()); }
http = (HttpsURLConnection)url.openConnection(); HttpsURLConnection http = null;
try {
InputStream is = http.getInputStream (); URL url = new URL("https://localhost:"+serverPort);
} catch (SocketTimeoutException stex) {
done(); // set read timeout through system property
http.disconnect(); System.setProperty("sun.net.client.defaultReadTimeout", "2000");
} HttpsURLConnection.setDefaultHostnameVerifier(
new NameVerifier());
http = (HttpsURLConnection)url.openConnection();
InputStream is = http.getInputStream ();
} catch (SocketTimeoutException stex) {
done();
http.disconnect();
}
try { try {
URL url = new URL("https://localhost:"+serverPort); URL url = new URL("https://localhost:"+serverPort);
HttpsURLConnection.setDefaultHostnameVerifier( HttpsURLConnection.setDefaultHostnameVerifier(
new NameVerifier()); new NameVerifier());
http = (HttpsURLConnection)url.openConnection(); http = (HttpsURLConnection)url.openConnection();
// set read timeout through API // set read timeout through API
http.setReadTimeout(2000); http.setReadTimeout(2000);
InputStream is = http.getInputStream ();
} catch (SocketTimeoutException stex) {
done();
http.disconnect();
}
InputStream is = http.getInputStream ();
} catch (SocketTimeoutException stex) {
done();
http.disconnect();
}
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
}
} }
static class NameVerifier implements HostnameVerifier { static class NameVerifier implements HostnameVerifier {
......
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
* @bug 4423074 * @bug 4423074
* @summary Need to rebase all the duplicated classes from Merlin. * @summary Need to rebase all the duplicated classes from Merlin.
* This test will check out http POST * This test will check out http POST
* @run main/othervm Redirect
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
...@@ -139,28 +143,33 @@ public class Redirect { ...@@ -139,28 +143,33 @@ public class Redirect {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
/*
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
/* // Send HTTP POST request to server
* Wait for server to get started. URL url = new URL("https://localhost:"+serverPort);
*/
while (!serverReady) {
Thread.sleep(50);
}
// Send HTTP POST request to server
URL url = new URL("https://localhost:"+serverPort);
HttpsURLConnection.setDefaultHostnameVerifier( HttpsURLConnection.setDefaultHostnameVerifier(
new NameVerifier()); new NameVerifier());
HttpsURLConnection http = (HttpsURLConnection)url.openConnection(); HttpsURLConnection http = (HttpsURLConnection)url.openConnection();
try { try {
System.out.println("response header: "+http.getHeaderField(0)); System.out.println("response header: "+http.getHeaderField(0));
if (http.getResponseCode() != 200) { if (http.getResponseCode() != 200) {
throw new RuntimeException("test Failed"); throw new RuntimeException("test Failed");
}
} finally {
http.disconnect();
closeReady = true;
} }
} finally { } finally {
http.disconnect(); HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
closeReady = true;
} }
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
*/ */
/* @test /* @test
* @summary Https can not retry request
* @bug 4799427 * @bug 4799427
* @summary Https can not retry request
* @run main/othervm RetryHttps
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Yingxian Wang * @author Yingxian Wang
*/ */
...@@ -129,36 +133,41 @@ public class RetryHttps { ...@@ -129,36 +133,41 @@ public class RetryHttps {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
HostnameVerifier reservedHV =
/* HttpsURLConnection.getDefaultHostnameVerifier();
* Wait for server to get started.
*/
while (!serverReady) {
Thread.sleep(50);
}
try { try {
HttpsURLConnection http = null; /*
/* establish http connection to server */ * Wait for server to get started.
URL url = new URL("https://localhost:" + serverPort+"/file1"); */
System.out.println("url is "+url.toString()); while (!serverReady) {
HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier()); Thread.sleep(50);
http = (HttpsURLConnection)url.openConnection(); }
int respCode = http.getResponseCode(); try {
int cl = http.getContentLength(); HttpsURLConnection http = null;
InputStream is = http.getInputStream (); /* establish http connection to server */
int count = 0; URL url = new URL("https://localhost:" + serverPort+"/file1");
while (is.read() != -1 && count++ < cl); System.out.println("url is "+url.toString());
System.out.println("respCode1 = "+respCode); HttpsURLConnection.setDefaultHostnameVerifier(
Thread.sleep(2000); new NameVerifier());
url = new URL("https://localhost:" + serverPort+"/file2"); http = (HttpsURLConnection)url.openConnection();
http = (HttpsURLConnection)url.openConnection(); int respCode = http.getResponseCode();
respCode = http.getResponseCode(); int cl = http.getContentLength();
System.out.println("respCode2 = "+respCode); InputStream is = http.getInputStream ();
int count = 0;
} catch (IOException ioex) { while (is.read() != -1 && count++ < cl);
if (sslServerSocket != null) System.out.println("respCode1 = "+respCode);
sslServerSocket.close(); Thread.sleep(2000);
throw ioex; url = new URL("https://localhost:" + serverPort+"/file2");
http = (HttpsURLConnection)url.openConnection();
respCode = http.getResponseCode();
System.out.println("respCode2 = "+respCode);
} catch (IOException ioex) {
if (sslServerSocket != null)
sslServerSocket.close();
throw ioex;
}
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
} }
......
/* /*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4474255 * @bug 4474255
* @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection * @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection
* @run main/othervm ComHTTPSConnection
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
...@@ -198,44 +202,50 @@ public class ComHTTPSConnection { ...@@ -198,44 +202,50 @@ public class ComHTTPSConnection {
Thread.sleep(50); Thread.sleep(50);
} }
System.setProperty("java.protocol.handler.pkgs", HostnameVerifier reservedHV =
"com.sun.net.ssl.internal.www.protocol"); HttpsURLConnection.getDefaultHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
URL url = new URL("https://" + "localhost:" + serverPort +
"/etc/hosts");
URLConnection urlc = url.openConnection();
if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) {
throw new Exception(
"URLConnection ! instanceof " +
"com.sun.net.ssl.HttpsURLConnection");
}
BufferedReader in = null;
try { try {
in = new BufferedReader(new InputStreamReader( System.setProperty("java.protocol.handler.pkgs",
urlc.getInputStream())); "com.sun.net.ssl.internal.www.protocol");
String inputLine; HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
System.out.print("Client reading... ");
while ((inputLine = in.readLine()) != null) URL url = new URL("https://" + "localhost:" + serverPort +
System.out.println(inputLine); "/etc/hosts");
URLConnection urlc = url.openConnection();
System.out.println("Cipher Suite: " +
((HttpsURLConnection)urlc).getCipherSuite()); if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) {
X509Certificate[] certs = throw new Exception(
((HttpsURLConnection)urlc).getServerCertificateChain(); "URLConnection ! instanceof " +
for (int i = 0; i < certs.length; i++) { "com.sun.net.ssl.HttpsURLConnection");
System.out.println(certs[0]);
} }
in.close(); BufferedReader in = null;
} catch (SSLException e) { try {
if (in != null) in = new BufferedReader(new InputStreamReader(
urlc.getInputStream()));
String inputLine;
System.out.print("Client reading... ");
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
System.out.println("Cipher Suite: " +
((HttpsURLConnection)urlc).getCipherSuite());
X509Certificate[] certs =
((HttpsURLConnection)urlc).getServerCertificateChain();
for (int i = 0; i < certs.length; i++) {
System.out.println(certs[0]);
}
in.close(); in.close();
throw e; } catch (SSLException e) {
if (in != null)
in.close();
throw e;
}
System.out.println("Client reports: SUCCESS");
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
System.out.println("Client reports: SUCCESS");
} }
static class NameVerifier implements HostnameVerifier { static class NameVerifier implements HostnameVerifier {
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
* @bug 4484246 * @bug 4484246
* @summary When an application enables anonymous SSL cipher suite, * @summary When an application enables anonymous SSL cipher suite,
* Hostname verification is not required * Hostname verification is not required
* @run main/othervm ComHostnameVerifier
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
/* /*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 4474255 * @bug 4474255
* @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection * @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection
* @run main/othervm JavaxHTTPSConnection
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
...@@ -189,47 +193,53 @@ public class JavaxHTTPSConnection { ...@@ -189,47 +193,53 @@ public class JavaxHTTPSConnection {
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
/* HostnameVerifier reservedHV =
* Wait for server to get started. HttpsURLConnection.getDefaultHostnameVerifier();
*/ try {
while (!serverReady) { /*
Thread.sleep(50); * Wait for server to get started.
} */
while (!serverReady) {
Thread.sleep(50);
}
HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier()); HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
URL url = new URL("https://" + "localhost:" + serverPort + URL url = new URL("https://" + "localhost:" + serverPort +
"/etc/hosts"); "/etc/hosts");
URLConnection urlc = url.openConnection(); URLConnection urlc = url.openConnection();
if (!(urlc instanceof javax.net.ssl.HttpsURLConnection)) { if (!(urlc instanceof javax.net.ssl.HttpsURLConnection)) {
throw new Exception( throw new Exception("URLConnection ! instanceof " +
"URLConnection ! instanceof javax.net.ssl.HttpsURLConnection"); "javax.net.ssl.HttpsURLConnection");
}
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(
urlc.getInputStream()));
String inputLine;
System.out.print("Client reading... ");
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
System.out.println("Cipher Suite: " +
((HttpsURLConnection)urlc).getCipherSuite());
Certificate[] certs =
((HttpsURLConnection)urlc).getServerCertificates();
for (int i = 0; i < certs.length; i++) {
System.out.println(certs[0]);
} }
in.close(); BufferedReader in = null;
} catch (SSLException e) { try {
if (in != null) in = new BufferedReader(new InputStreamReader(
urlc.getInputStream()));
String inputLine;
System.out.print("Client reading... ");
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
System.out.println("Cipher Suite: " +
((HttpsURLConnection)urlc).getCipherSuite());
Certificate[] certs =
((HttpsURLConnection)urlc).getServerCertificates();
for (int i = 0; i < certs.length; i++) {
System.out.println(certs[0]);
}
in.close(); in.close();
throw e; } catch (SSLException e) {
if (in != null)
in.close();
throw e;
}
System.out.println("Client reports: SUCCESS");
} finally {
HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
} }
System.out.println("Client reports: SUCCESS");
} }
static class NameVerifier implements HostnameVerifier { static class NameVerifier implements HostnameVerifier {
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
* @bug 4484246 * @bug 4484246
* @summary When an application enables anonymous SSL cipher suite, * @summary When an application enables anonymous SSL cipher suite,
* Hostname verification is not required * Hostname verification is not required
* @run main/othervm JavaxHostnameVerifier
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
import java.io.*; import java.io.*;
......
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
* @test * @test
* @bug 1234567 * @bug 1234567
* @summary SSLEngine has not yet caused Solaris kernel to panic * @summary SSLEngine has not yet caused Solaris kernel to panic
* @run main/othervm SSLEngineTemplate
* *
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
*/ */
/** /**
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
* @test * @test
* @bug 1234567 * @bug 1234567
* @summary Use this template to help speed your client/server tests. * @summary Use this template to help speed your client/server tests.
* @run main/othervm SSLSocketTemplate
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
...@@ -132,7 +132,9 @@ public class StartDateTest { ...@@ -132,7 +132,9 @@ public class StartDateTest {
static Date getIssueDate() throws Exception { static Date getIssueDate() throws Exception {
KeyStore ks = KeyStore.getInstance("jks"); KeyStore ks = KeyStore.getInstance("jks");
ks.load(new FileInputStream("jks"), "changeit".toCharArray()); try (FileInputStream fis = new FileInputStream("jks")) {
ks.load(fis, "changeit".toCharArray());
}
X509Certificate cert = (X509Certificate)ks.getCertificate("me"); X509Certificate cert = (X509Certificate)ks.getCertificate("me");
return cert.getNotBefore(); return cert.getNotBefore();
} }
......
...@@ -24,9 +24,12 @@ ...@@ -24,9 +24,12 @@
/* /*
* @test * @test
* @bug 4162868 * @bug 4162868
* @run main/othervm ExtensibleAlgorithmId
* @summary Algorithm Name-to-OID mapping needs to be made extensible. * @summary Algorithm Name-to-OID mapping needs to be made extensible.
*/ */
// Run in othervm, coz AlgorithmId.oidTable is only initialized once
import java.security.*; import java.security.*;
import sun.security.x509.AlgorithmId; import sun.security.x509.AlgorithmId;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册