test.sh 2.4 KB

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