From 59c78980548b7753b76f416fbd91b5309fb55ba4 Mon Sep 17 00:00:00 2001 From: brian Date: Wed, 28 Jul 2004 12:01:34 +0000 Subject: [PATCH] more advanced make check darcs-hash:20040728120134-24bed-5efe59511c1511164eb0df5ca0ec8965f5004dcc.gz --- Makefile | 5 ++++- src/org/ibex/net/ssl/Test.java | 41 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9503004..68007d8 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,10 @@ $(jar): $(classes) cd build && jar cf ../$@ $(jar_classes:build/%.class=%*.class) test: all - java -cp build org.ibex.net.ssl.Test www.paypal.com 443 + java -cp build org.ibex.net.ssl.Test ssl.brianweb.net 443 + +check: all + java -cp build org.ibex.net.ssl.Test check clean: rm -rf build/* diff --git a/src/org/ibex/net/ssl/Test.java b/src/org/ibex/net/ssl/Test.java index aa43ccb..10e0656 100644 --- a/src/org/ibex/net/ssl/Test.java +++ b/src/org/ibex/net/ssl/Test.java @@ -6,6 +6,7 @@ import java.io.*; public class Test { public static void main(String[] args) throws Exception { SSL.debugOn = true; + if(args.length == 1 && args[0].equals("check")) System.exit(check()); if(args.length < 2) { System.err.println("Usage: SSL host port"); } String host = args[0]; int port = Integer.parseInt(args[1]); @@ -21,12 +22,46 @@ public class Test { cat(ssl.getInputStream()); ssl.close(); } - private static void cat(InputStream is) throws IOException { + private static void cat(InputStream is) throws IOException { cat(is,100,null); } + private static void cat(InputStream is, int count, String check) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; - int count = 100; try { - while((line = br.readLine()) != null && --count >= 0) System.out.println(line); + while((line = br.readLine()) != null && --count >= 0) { + if(check != null) { + if(!line.startsWith(check)) throw new Error("\"" + check + "\" check failed"); + check = null; + } + System.out.println(line); + } } catch(SSL.PrematureCloseExn e) { /* ignore */ } } + public static int check() throws Exception { + byte[] ciphers = new byte[] { + SSL.TLS_RSA_WITH_AES_256_CBC_SHA,SSL.TLS_RSA_WITH_AES_128_CBC_SHA, + SSL.SSL_RSA_WITH_RC4_128_SHA,SSL.SSL_RSA_WITH_RC4_128_MD5 + }; + String[] hosts = new String[] { + "ssl.brianweb.net", "www.zaks.com", "www.paypal.com", "www99.americanexpress.com", "www.cnbank.com", "gmail.google.com" + }; + int[] blacklisted = new int[] { 0,3,2,3,3,0 }; + for(int i=0;i