1#!/bin/sh 2 3HTTP="localhost:8080" 4CLIENT_PORT="9020" 5SERVER_PORT="9021" 6 7sub_test () 8{ 9 echo "STARTING - $VER $CIPHER" 10 ./tunala -listen localhost:$CLIENT_PORT -proxy localhost:$SERVER_PORT \ 11 -cacert CA.pem -cert A-client.pem -server 0 \ 12 -dh_special standard -v_peer -v_strict \ 13 $VER -cipher $CIPHER 1> tc1.txt 2> tc2.txt & 14 ./tunala -listen localhost:$SERVER_PORT -proxy $HTTP \ 15 -cacert CA.pem -cert A-server.pem -server 1 \ 16 -dh_special standard -v_peer -v_strict \ 17 $VER -cipher $CIPHER 1> ts1.txt 2> ts2.txt & 18 # Wait for the servers to be listening before starting the wget test 19 DONE="no" 20 while [ "$DONE" != "yes" ]; do 21 L1=`netstat -a | egrep "LISTEN[\t ]*$" | grep ":$CLIENT_PORT"` 22 L2=`netstat -a | egrep "LISTEN[\t ]*$" | grep ":$SERVER_PORT"` 23 if [ "x$L1" != "x" ]; then 24 DONE="yes" 25 elif [ "x$L2" != "x" ]; then 26 DONE="yes" 27 else 28 sleep 1 29 fi 30 done 31 HTML=`wget -O - -T 1 http://localhost:$CLIENT_PORT 2> /dev/null | grep "<HTML>"` 32 if [ "x$HTML" != "x" ]; then 33 echo "OK - $CIPHER ($VER)" 34 else 35 echo "FAIL - $CIPHER ($VER)" 36 killall tunala 37 exit 1 38 fi 39 killall tunala 40 # Wait for the servers to stop before returning - otherwise the next 41 # test my fail to start ... (fscking race conditions) 42 DONE="yes" 43 while [ "$DONE" != "no" ]; do 44 L1=`netstat -a | egrep "LISTEN[\t ]*$" | grep ":$CLIENT_PORT"` 45 L2=`netstat -a | egrep "LISTEN[\t ]*$" | grep ":$SERVER_PORT"` 46 if [ "x$L1" != "x" ]; then 47 DONE="yes" 48 elif [ "x$L2" != "x" ]; then 49 DONE="yes" 50 else 51 DONE="no" 52 fi 53 done 54 exit 0 55} 56 57run_test () 58{ 59 (sub_test 1> /dev/null) || exit 1 60} 61 62run_ssl_test () 63{ 64killall tunala 1> /dev/null 2> /dev/null 65echo "" 66echo "Starting all $PRETTY tests" 67if [ "$PRETTY" != "SSLv2" ]; then 68 if [ "$PRETTY" != "SSLv3" ]; then 69 export VER="-no_ssl2 -no_ssl3" 70 export OSSL="-tls1" 71 else 72 export VER="-no_ssl2 -no_tls1" 73 export OSSL="-ssl3" 74 fi 75else 76 export VER="-no_ssl3 -no_tls1" 77 export OSSL="-ssl2" 78fi 79LIST="`../../apps/openssl ciphers $OSSL | sed -e 's/:/ /g'`" 80#echo "$LIST" 81for i in $LIST; do \ 82 DSS=`echo "$i" | grep "DSS"` 83 if [ "x$DSS" != "x" ]; then 84 echo "---- skipping $i (no DSA cert/keys) ----" 85 else 86 export CIPHER=$i 87 run_test 88 echo "SUCCESS: $i" 89 fi 90done; 91} 92 93# Welcome the user 94echo "Tests will assume an http server running at $HTTP" 95 96# TLSv1 test 97export PRETTY="TLSv1" 98run_ssl_test 99 100# SSLv3 test 101export PRETTY="SSLv3" 102run_ssl_test 103 104# SSLv2 test 105export PRETTY="SSLv2" 106run_ssl_test 107 108