311934 added PORT_JSSE_SERVER and PORT_JSSE_SERVER plus testing bypass r=sandeep

This commit is contained in:
glen.beasley%sun.com 2005-11-03 23:30:38 +00:00
parent 972005ad9a
commit 3033b29443
9 changed files with 191 additions and 58 deletions

View File

@ -109,12 +109,21 @@ public abstract class ClassServer implements Runnable {
"communication test :");
System.out.println("-------------------------------------------" +
"-------------");
for ( int i=0; i<supportedCiphers.size(); i++ ) {
for ( int j=0; j<Constants.jssCipherSuites.length; j++ ) {
if ( new Integer(
(String)supportedCiphers.elementAt(i)).intValue() ==
Constants.jssCipherSuites[j] ) {
System.out.println("["+i+"]\t" +
System.out.println("supportedCiphers.size " + supportedCiphers.size());
System.out.println("Constants.jssCiphersSuites "+
Constants.jssCipherSuites.length);
System.out.println("Constants.jssCiphersNames " +
Constants.jssCipherNames.length);
for ( int i=0; i<(supportedCiphers.size()-1); i++ ) {
System.out.print(i + " SC " +
new Integer((String)supportedCiphers.elementAt(i)).intValue());
for ( int j=0; j<(Constants.jssCipherSuites.length-1); j++ ) {
if (new Integer((String)supportedCiphers.elementAt(i)).intValue()
== Constants.jssCipherSuites[j] ) {
System.out.print(" JSSC " + Constants.jssCipherSuites[j] );
System.out.println(" ["+ i +"]\t" +
Constants.jssCipherNames[j]);
System.out.flush();
}

View File

@ -302,7 +302,8 @@ public class JSSE_SSLClient {
try {
ks.load(new FileInputStream(getKeystoreLoc()), passphrase);
} catch (Exception keyEx) {
System.out.println("DEBUG 306: Exception : " + keyEx.getMessage());
System.out.println(keyEx.getMessage());
System.exit(1);
}
kmf.init(ks, passphrase);
@ -656,19 +657,26 @@ public class JSSE_SSLClient {
int testPort = 29750;
String usage = "java org.mozilla.jss.tests.JSSE_SSLClient" +
"\n<keystore location> " +
"<test cipher> <test host> <test port>";
"<test port> <test cipher> <test host> ";
try {
if ( args[0].toLowerCase().equals("-h") ) {
if ( args[0].toLowerCase().equals("-h") || args.length < 1) {
System.out.println(usage);
System.exit(0);
System.exit(1);
}
if ( args.length >= 1 ) {
keystoreLocation = (String)args[0];
testCipher = (String)args[1];
testHost = (String)args[2];
testPort = new Integer(args[3]).intValue();
}
if ( args.length >= 2) {
testPort = new Integer(args[1]).intValue();
System.out.println("using port: " + testPort);
}
if ( args.length >= 3) {
testCipher = (String)args[2];
}
if ( args.length == 4) {
testHost = (String)args[3];
}
} catch (Exception e) { }
@ -685,5 +693,6 @@ public class JSSE_SSLClient {
Thread.currentThread().sleep(1000);
} catch (Exception e) { }
sslSock.testSslClient(testCipher, testHost, testPort, keystoreLocation);
System.exit(0);
}
}

View File

@ -49,7 +49,7 @@ public class JSSE_SSLServer extends ClassServer {
private static int port = DefaultServerPort;
private static String type = "SSLv3";
private static String keystoreLoc = "keystore.pfx";
private static boolean bClientAuth = false;
/**
* Constructs a JSSE_SSLServer.
* @param path the path where the server locates files
@ -90,23 +90,36 @@ public class JSSE_SSLServer extends ClassServer {
String keystoreLoc = "keystore.pfx";
if ( args.length <= 1 ) {
System.out.println(
"USAGE: java JSSE_SSLServer port [TLS | SSLv3 [true]]");
System.out.println("<keystore location>");
"USAGE: java JSSE_SSLServer [port] [TLS | SSLv3 [true]]");
System.out.println("[keystore location]");
System.out.println(
"\nIf the second argument is TLS, it will start as a\n" +
"TLS server, otherwise, it will be started in SSLv3 mode." +
"\nIf the third argument is true,it will require\n" +
"client authentication as well.");
System.exit(0);
System.exit(1);
}
if (args.length >= 2) {
if (args.length >= 1) {
port = Integer.parseInt(args[0]);
type = args[1];
keystoreLoc = args[3];
if ( keystoreLoc != null )
setKeystoreLoc(keystoreLoc);
}
if (args.length >= 2) {
type = args[1];
}
if (args.length >= 3 && args[2].equals("true")) {
bClientAuth = true;
}
if (args.length >= 4) {
keystoreLoc = args[3];
if ( keystoreLoc != null ) {
setKeystoreLoc(keystoreLoc);
}
}
System.out.println("using port: " + port);
System.out.println ("mode type " + type +
(bClientAuth ? "true" : "false"));
System.out.println("keystoreLoc" + keystoreLoc);
try {
SSLServerSocketFactory ssf =
@ -123,10 +136,7 @@ public class JSSE_SSLServer extends ClassServer {
System.out.println("*** Using J2SE 1.5.x ***");
ss.setEnabledCipherSuites(Constants.sslciphersarray_jdk150);
}
if (args.length >= 3 && args[2].equals("true")) {
((SSLServerSocket)ss).setNeedClientAuth(true);
}
((SSLServerSocket)ss).setNeedClientAuth(bClientAuth);
new JSSE_SSLServer(ss);
} catch (IOException e) {
System.out.println("Unable to start ClassServer: " +

View File

@ -57,6 +57,7 @@ public class JSS_SSLClient {
private String clientCertNick = null;
private String serverHost = null;
private boolean TestCertCallBack = false;
private boolean testBypass = false;
private boolean success = true;
private int fCipher = -1;
private int port = 29753;
@ -132,6 +133,14 @@ public class JSS_SSLClient {
return fCertDbPath;
}
/**
* Enable/disable Test Cert Callback.
* @param boolean
*/
public void setBypass(boolean bypass) {
testBypass = bypass;
}
/**
* Enable/disable Test Cert Callback.
* @param boolean
@ -222,6 +231,10 @@ public class JSS_SSLClient {
port);
}
if (testBypass) {
//enable bypass for this socket.
sock.bypassPKCS11(true);
}
if ( Constants.debug_level >= 3 )
System.out.println("clientCertNick=" + clientCertNick);
sock.setClientCertNickname(clientCertNick);
@ -312,16 +325,18 @@ public class JSS_SSLClient {
int testport = 29753;
String certDbPath = null;
String passwdFile = "passwords";
boolean bypass = false;
String usage = "USAGE:\n" +
"java org.mozilla.jss.tests.JSS_SSLClient" +
" <cert db path> <password file>\n" +
" <test cipher> <server host> <server port>";
" [server port] [bypass] [test cipher] [server host] ";
try {
if ( ((String)args[0]).toLowerCase().equals("-h") ) {
if ( ((String)args[0]).toLowerCase().equals("-h") ||
args.length < 2) {
System.out.println(usage);
System.exit(0);
System.exit(1);
}
if ( args.length >= 2 ) {
@ -332,14 +347,25 @@ public class JSS_SSLClient {
if ( certDbPath != null)
setCertDbPath(certDbPath);
if ( args.length >= 3 ) {
testCipher = new Integer(args[2]).intValue();
if ( args.length >= 3) {
testport = new Integer(args[2]).intValue();
System.out.println("using port: " + testport);
}
if ( args.length >= 5 ) {
testhost = (String)args[3];
testport = new Integer(args[4]).intValue();
if ((args.length >= 4) &&
args[3].equalsIgnoreCase("bypass")== true) {
bypass = true;
}
if ( args.length >= 5 ) {
testCipher = new Integer(args[4]).intValue();
System.out.println("testCipher " + testCipher);
}
if ( args.length == 6 ) {
testhost = (String)args[5];
System.out.println("testhost" + testhost);
}
Thread.sleep(5000);
} catch (Exception e) {
System.out.println("Exception caught " + e.toString());
@ -354,6 +380,7 @@ public class JSS_SSLClient {
if ( testport != 29753 )
jssTest.setPort(testport);
jssTest.setBypass(bypass);
jssTest.setTestCertCallback(true);
jssTest.setClientCertNick(certnick);

View File

@ -88,17 +88,17 @@ public class JSS_SSLServer {
private String serverHost = "localhost";
private boolean TestInetAddress = false;
private boolean success = true;
public static int port = 29750;
public int port = 29750;
public static String usage = "USAGE: java JSS_SSLServer " +
"<cert db path> passwords server_name " +
"servercertnick [ true | false ]";
"<cert db path> <passwords> <server_name> " +
"<servercertnick> [ true | false ] [ portNumber ] [ bypass ]";
public void doIt(String[] args) throws Exception {
if ( args.length < 1 ) {
if ( args.length < 4 ) {
System.out.println(usage);
System.exit(0);
}
System.exit(1);
}
CryptoManager.initialize(args[0]);
CryptoManager cm = CryptoManager.getInstance();
@ -108,8 +108,19 @@ public class JSS_SSLServer {
serverHost = args[2]; // localhost
serverCertNick = args[3]; // servercertnick
if (args[4].equalsIgnoreCase("true") == true) {
if ((args.length >= 5) && args[4].equalsIgnoreCase("true") == true) {
TestInetAddress = true;
System.out.println("testing Inet Address");
}
if ((args.length >= 6)) {
port = new Integer(args[5]).intValue();
System.out.println("using port: " + port);
}
if ((args.length == 7) && args[6].equalsIgnoreCase("bypass")== true) {
org.mozilla.jss.ssl.SSLSocket.bypassPKCS11Default(true);
System.out.println("enabled bypassPKCS11 mode for all sockets");
}
// We have to configure the server session ID cache before

View File

@ -67,7 +67,7 @@ public class SSLClientAuth implements Runnable {
{
AlgorithmIdentifier sigAlgID = new AlgorithmIdentifier( sigAlg.toOID());
Name issuer = new Name();
Name issuer = new Name();
issuer.addCommonName(issuerName);
issuer.addCountryName("US");
issuer.addOrganizationName("Mozilla"+rand);
@ -110,9 +110,10 @@ public class SSLClientAuth implements Runnable {
public void doIt(String[] args) throws Exception {
if ( args.length != 2 ) {
System.out.println("Usage: java org.mozilla.jss.tests." +
"SSLClientAuth <dbdir> <passwordFile>");
if ( args.length < 2 ) {
System.out.println("Usage: java org.mozilla.jss.tests." +
"SSLClientAuth <dbdir> <passwordFile> [port]" +
" [bypass]");
System.exit(1);
}
@ -124,11 +125,20 @@ public class SSLClientAuth implements Runnable {
PasswordCallback cb = new FilePasswordCallback(args[1]);
tok.login(cb);
if (args.length == 3) {
port = new Integer(args[2]).intValue();
System.out.println("using port:" + port);
}
if (args.length == 4 && (args[3].equalsIgnoreCase("bypass") == true)) {
org.mozilla.jss.ssl.SSLSocket.bypassPKCS11Default(true);
System.out.println("enabled bypassPKCS11 mode for all sockets");
System.out.println(SSLSocket.getSSLDefaultOptions());
}
SecureRandom rng= SecureRandom.getInstance("pkcs11prng",
"Mozilla-JSS");
int rand = nextRandInt(rng);
// generate CA cert
// 512-bit RSA Key with default exponent
java.security.KeyPairGenerator kpg =
@ -254,7 +264,7 @@ public class SSLClientAuth implements Runnable {
private boolean success = true;
public static int port = 29752;
public int port = 29752;
public boolean serverReady = false;

View File

@ -65,6 +65,8 @@ my $lib_suffix = ".so";
my $lib_jss = "libjss";
my $jss_rel_dir = "";
my $jss_classpath = "";
my $portJSSEServer = 2876;
my $portJSSServer = 2877;
sub setup_vars {
my $argv = shift;
@ -95,6 +97,7 @@ sub setup_vars {
$ENV{CLASSPATH} = "";
$ENV{$ld_lib_path} = "" if $truncate_lib_path;
if( $$argv[0] eq "dist" ) {
shift @$argv;
$dist_dir = shift @$argv or usage("did not provide dist_dir");
@ -131,6 +134,14 @@ sub setup_vars {
usage();
}
if ($ENV{PORT_JSSE_SERVER}) {
$portJSSEServer = $ENV{PORT_JSSE_SERVER};
}
if ($ENV{PORT_JSS_SERVER}) {
$portJSSServer = $ENV{PORT_JSS_SERVER};
}
unless( $ENV{JAVA_HOME} ) {
print "Must set JAVA_HOME environment variable\n";
exit(1);
@ -177,6 +188,8 @@ sub setup_vars {
print "CLASSPATH=$ENV{CLASSPATH}\n";
print "USE_64=$ENV{USE_64}\n";
print "testdir=$testdir\n";
print "portJSSEServer=$portJSSEServer\n";
print "portJSSServer=$portJSSServer\n";
}
sub print_case_result {
@ -243,7 +256,7 @@ print_case_result ($result,"List CA certs");
# test sockets
#
print "============= test sockets\n";
$result = system("$java org.mozilla.jss.tests.SSLClientAuth $testdir $pwfile");
$result = system("$java org.mozilla.jss.tests.SSLClientAuth $testdir $pwfile $portJSSServer");
$result >>=8;
$result and print "SSLClientAuth returned $result\n";
print_case_result ($result,"Sockets");
@ -256,7 +269,6 @@ $result >>=8;
$result and print "TestKeyGen returned $result\n";
print_case_result ($result,"Key generation");
# test KeyFactory
#
print "============= test KeyFactory\n";
@ -265,7 +277,6 @@ $result >>=8;
$result and print "KeyFactoryTest returned $result\n";
print_case_result ($result,"KeyFactoryTest");
# test digesting
#
print "============= test digesting\n";
@ -328,7 +339,7 @@ $result and print "Convert PKCS11 to PKCS12 returned $result\n";
# Start JSSE server
#
print "============= Start JSSE server tests\n";
$result=system("./startJsseServ.$scriptext $jss_classpath $testdir $java");
$result=system("./startJsseServ.$scriptext $jss_classpath $testdir $portJSSEServer");
$result >>=8;
$result and print "JSSE servers returned $result\n";
@ -336,7 +347,7 @@ $result and print "JSSE servers returned $result\n";
# Test JSS client communication
#
print "============= Start JSS client tests\n";
$result = system("$java org.mozilla.jss.tests.JSS_SSLClient $testdir $pwfile");
$result = system("$java org.mozilla.jss.tests.JSS_SSLClient $testdir $pwfile $portJSSEServer bypassOff");
$result >>=8;
$result and print "JSS client returned $result\n";
print_case_result ($result,"JSSE server / JSS client");
@ -345,7 +356,7 @@ print_case_result ($result,"JSSE server / JSS client");
# Start JSS server
#
print "============= Start JSS server tests\n";
$result=system("./startJssServ.$scriptext $jss_classpath $testdir $java");
$result=system("./startJssServ.$scriptext $jss_classpath $testdir $portJSSServer bypassOff");
$result >>=8;
$result and print "JSS servers returned $result\n";
@ -353,7 +364,7 @@ $result and print "JSS servers returned $result\n";
# Test JSSE client communication
#
print "============= Start JSSE client tests\n";
$result = system("$java org.mozilla.jss.tests.JSSE_SSLClient $testdir");
$result = system("$java org.mozilla.jss.tests.JSSE_SSLClient $testdir $portJSSServer");
$result >>=8;
$result and print "JSSE client returned $result\n";
print_case_result ($result,"JSS server / JSSE client");
@ -376,6 +387,49 @@ $result >>=8;
$result and print "Disable FIPSMODE returned $result\n";
print_case_result ($result,"FIPSMODE disabled");
#
# test sockets in bypass mode
#
print "============= test sockets using bypass \n";
$result = system("$java org.mozilla.jss.tests.SSLClientAuth $testdir $pwfile $portJSSServer bypass");
$result >>=8;
$result and print "SSLClientAuth using bypass mode returned $result\n";
print_case_result ($result,"SSLClientAuth using bypass");
#
# Start JSSE server to test JSS client in bypassPKCS11 mode
#
print "============= Start JSSE server tests to test the bypass\n";
$result=system("./startJsseServ.$scriptext $jss_classpath $testdir $portJSSEServer");
$result >>=8;
$result and print "JSSE servers testing JSS client in bypassPKCS11 test returned $result\n";
#
# Test JSS in bypassPKCS11 mode client communication
#
print "============= Start JSS client tests in bypassPKCS11 mode\n";
$result = system("$java org.mozilla.jss.tests.JSS_SSLClient $testdir $pwfile $portJSSEServer bypass");
$result >>=8;
$result and print "JSS client in bypassPKCS11 mode returned $result\n";
print_case_result ($result,"JSSE server / JSS client in bypassPKCS11 mode");
#
# Start JSS server in bypassPKCS11 mode
#
print "============= Start JSS server tests in bypassPKCS11 mode\n";
$result=system("./startJssServ.$scriptext $jss_classpath $testdir $portJSSServer bypass");
$result >>=8;
$result and print "JSS servers in bypassPKCS11 mode returned $result\n";
#
# Test JSSE client communication
#
print "============= Start JSSE client tests to test the JSS server in bypassPKCS11 mode\n";
$result = system("$java org.mozilla.jss.tests.JSSE_SSLClient $testdir $portJSSServer");
$result >>=8;
$result and print "JSSE client talking to JSS Server in bypassPKCS11 mode returned $result\n";
print_case_result ($result,"JSS server in bypassPKCS11 mode / JSSE client");
#
# Test for JSS jar and library revision
#

View File

@ -42,7 +42,9 @@
#
JSS_CLASSPATH=$1
TESTDIR=$2
shift 2
Port=$3
Bypass=$4
shift 4
JAVA_BIN_AND_OPT=$@
if [ -z "$JAVA_BIN_AND_OPT" ] ;
@ -50,5 +52,5 @@ then
JAVA_BIN_AND_OPT=${JAVA_HOME}/bin/java
fi
${JAVA_BIN_AND_OPT} -classpath ${JSS_CLASSPATH} org.mozilla.jss.tests.JSS_SSLServer ${TESTDIR} passwords localhost JSSCATestCert true &
${JAVA_BIN_AND_OPT} -classpath ${JSS_CLASSPATH} org.mozilla.jss.tests.JSS_SSLServer ${TESTDIR} passwords localhost JSSCATestCert true ${Port} ${Bypass} &

View File

@ -42,7 +42,8 @@
#
JSS_CLASSPATH=$1
TESTDIR=$2
shift 2
Port=$3
shift 3
JAVA_BIN_AND_OPT=$@
if [ -z "$JAVA_BIN_AND_OPT" ] ;
@ -50,5 +51,5 @@ then
JAVA_BIN_AND_OPT=${JAVA_HOME}/bin/java
fi
${JAVA_BIN_AND_OPT} -classpath ${JSS_CLASSPATH} org.mozilla.jss.tests.JSSE_SSLServer 29753 SSLv3 false ${TESTDIR} &
${JAVA_BIN_AND_OPT} -classpath ${JSS_CLASSPATH} org.mozilla.jss.tests.JSSE_SSLServer ${Port} SSLv3 false ${TESTDIR} &