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