security/nss/tests/iopr/ssl_iopr.sh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 #! /bin/bash
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 ########################################################################
michael@0 8 #
michael@0 9 # mozilla/security/nss/tests/iopr/ssl_iopr.sh
michael@0 10 #
michael@0 11 # NSS SSL interoperability QA. This file is included from ssl.sh
michael@0 12 #
michael@0 13 # needs to work on all Unix and Windows platforms
michael@0 14 #
michael@0 15 # special strings
michael@0 16 # ---------------
michael@0 17 # FIXME ... known problems, search for this string
michael@0 18 # NOTE .... unexpected behavior
michael@0 19 ########################################################################
michael@0 20 IOPR_SSL_SOURCED=1
michael@0 21
michael@0 22 ########################################################################
michael@0 23 # The functions works with variables defined in interoperability
michael@0 24 # configuration file that was downloaded from a webserver.
michael@0 25 # It tries to find unrevoked cert based on value of variable
michael@0 26 # "SslClntValidCertName" defined in the configuration file.
michael@0 27 # Params NONE.
michael@0 28 # Returns 0 if found, 1 otherwise.
michael@0 29 #
michael@0 30 setValidCert() {
michael@0 31 testUser=$SslClntValidCertName
michael@0 32 [ -z "$testUser" ] && return 1
michael@0 33 return 0
michael@0 34 }
michael@0 35
michael@0 36 ########################################################################
michael@0 37 # The funtions works with variables defined in interoperability
michael@0 38 # configuration file that was downloaded from a webserver.
michael@0 39 # The function sets port, url, param and description test parameters
michael@0 40 # that was defind for a particular type of testing.
michael@0 41 # Params:
michael@0 42 # $1 - supported types of testing. Currently have maximum
michael@0 43 # of two: forward and reverse. But more can be defined.
michael@0 44 # No return value
michael@0 45 #
michael@0 46 setTestParam() {
michael@0 47 type=$1
michael@0 48 sslPort=`eval 'echo $'${type}Port`
michael@0 49 sslUrl=`eval 'echo $'${type}Url`
michael@0 50 testParam=`eval 'echo $'${type}Param`
michael@0 51 testDescription=`eval 'echo $'${type}Descr`
michael@0 52 [ -z "$sslPort" ] && sslPort=443
michael@0 53 [ -z "$sslUrl" ] && sslUrl="/iopr_test/test_pg.html"
michael@0 54 [ "$sslUrl" = "/" ] && sslUrl="/test_pg.html"
michael@0 55 }
michael@0 56
michael@0 57
michael@0 58 #######################################################################
michael@0 59 # local shell function to perform SSL Cipher Suite Coverage tests
michael@0 60 # in interoperability mode. Tests run against web server by using nss
michael@0 61 # test client
michael@0 62 # Params:
michael@0 63 # $1 - supported type of testing.
michael@0 64 # $2 - testing host
michael@0 65 # $3 - nss db location
michael@0 66 # No return value
michael@0 67 #
michael@0 68 ssl_iopr_cov_ext_server()
michael@0 69 {
michael@0 70 testType=$1
michael@0 71 host=$2
michael@0 72 dbDir=$3
michael@0 73
michael@0 74 setTestParam $testType
michael@0 75 if [ "`echo $testParam | grep NOCOV`" != "" ]; then
michael@0 76 echo "SSL Cipher Coverage of WebServ($IOPR_HOSTADDR) excluded from " \
michael@0 77 "run by server configuration"
michael@0 78 return 0
michael@0 79 fi
michael@0 80
michael@0 81 html_head "SSL Cipher Coverage of WebServ($IOPR_HOSTADDR" \
michael@0 82 "$BYPASS_STRING $NORM_EXT): $testDescription"
michael@0 83
michael@0 84 setValidCert; ret=$?
michael@0 85 if [ $ret -ne 0 ]; then
michael@0 86 html_failed "Fail to find valid test cert(ws: $host)"
michael@0 87 return $ret
michael@0 88 fi
michael@0 89
michael@0 90 SSL_REQ_FILE=${TMP}/sslreq.dat.$$
michael@0 91 echo "GET $sslUrl HTTP/1.0" > $SSL_REQ_FILE
michael@0 92 echo >> $SSL_REQ_FILE
michael@0 93
michael@0 94 while read ecc tls param testname therest; do
michael@0 95 [ -z "$ecc" -o "$ecc" = "#" -o "`echo $testname | grep FIPS`" -o \
michael@0 96 "$ecc" = "ECC" ] && continue;
michael@0 97
michael@0 98 echo "$SCRIPTNAME: running $testname ----------------------------"
michael@0 99 TLS_FLAG=-T
michael@0 100 if [ "$tls" = "TLS" ]; then
michael@0 101 TLS_FLAG=""
michael@0 102 fi
michael@0 103
michael@0 104 resFile=${TMP}/$HOST.tmpRes.$$
michael@0 105 rm $resFile 2>/dev/null
michael@0 106
michael@0 107 echo "tstclnt -p ${sslPort} -h ${host} -c ${param} ${TLS_FLAG} \\"
michael@0 108 echo " -n $testUser -v -w nss ${CLIEN_OPTIONS} -f \\"
michael@0 109 echo " -d ${dbDir} < ${SSL_REQ_FILE} > $resFile"
michael@0 110
michael@0 111 ${BINDIR}/tstclnt -p ${sslPort} -h ${host} -c ${param} \
michael@0 112 ${TLS_FLAG} ${CLIEN_OPTIONS} -f -n $testUser -v -w nss \
michael@0 113 -d ${dbDir} < ${SSL_REQ_FILE} >$resFile 2>&1
michael@0 114 ret=$?
michael@0 115 grep "ACCESS=OK" $resFile
michael@0 116 test $? -eq 0 -a $ret -eq 0
michael@0 117 ret=$?
michael@0 118 [ $ret -ne 0 ] && cat $resFile
michael@0 119 rm -f $resFile 2>/dev/null
michael@0 120 html_msg $ret 0 "${testname}"
michael@0 121 done < ${SSLCOV}
michael@0 122 rm -f $SSL_REQ_FILE 2>/dev/null
michael@0 123
michael@0 124 html "</TABLE><BR>"
michael@0 125 }
michael@0 126
michael@0 127 #######################################################################
michael@0 128 # local shell function to perform SSL Client Authentication tests
michael@0 129 # in interoperability mode. Tests run against web server by using nss
michael@0 130 # test client
michael@0 131 # Params:
michael@0 132 # $1 - supported type of testing.
michael@0 133 # $2 - testing host
michael@0 134 # $3 - nss db location
michael@0 135 # No return value
michael@0 136 #
michael@0 137 ssl_iopr_auth_ext_server()
michael@0 138 {
michael@0 139 testType=$1
michael@0 140 host=$2
michael@0 141 dbDir=$3
michael@0 142
michael@0 143 setTestParam $testType
michael@0 144 if [ "`echo $testParam | grep NOAUTH`" != "" ]; then
michael@0 145 echo "SSL Client Authentication WebServ($IOPR_HOSTADDR) excluded from " \
michael@0 146 "run by server configuration"
michael@0 147 return 0
michael@0 148 fi
michael@0 149
michael@0 150 html_head "SSL Client Authentication WebServ($IOPR_HOSTADDR $BYPASS_STRING $NORM_EXT):
michael@0 151 $testDescription"
michael@0 152
michael@0 153 setValidCert;ret=$?
michael@0 154 if [ $ret -ne 0 ]; then
michael@0 155 html_failed "Fail to find valid test cert(ws: $host)"
michael@0 156 return $ret
michael@0 157 fi
michael@0 158
michael@0 159 SSL_REQ_FILE=${TMP}/sslreq.dat.$$
michael@0 160 echo "GET $sslUrl HTTP/1.0" > $SSL_REQ_FILE
michael@0 161 echo >> $SSL_REQ_FILE
michael@0 162
michael@0 163 SSLAUTH_TMP=${TMP}/authin.tl.tmp
michael@0 164 grep -v "^#" ${SSLAUTH} | grep -- "-r_-r_-r_-r" > ${SSLAUTH_TMP}
michael@0 165
michael@0 166 while read ecc value sparam cparam testname; do
michael@0 167 [ -z "$ecc" -o "$ecc" = "#" -o "$ecc" = "ECC" ] && continue;
michael@0 168
michael@0 169 cparam=`echo $cparam | sed -e 's;_; ;g' -e "s/TestUser/$testUser/g" `
michael@0 170
michael@0 171 echo "tstclnt -p ${sslPort} -h ${host} ${CLIEN_OPTIONS} -f ${cparam} \\"
michael@0 172 echo " -d ${dbDir} -v < ${SSL_REQ_FILE}"
michael@0 173
michael@0 174 resFile=${TMP}/$HOST.tmp.$$
michael@0 175 rm $rsFile 2>/dev/null
michael@0 176
michael@0 177 ${BINDIR}/tstclnt -p ${sslPort} -h ${host} ${CLIEN_OPTIONS} -f ${cparam} \
michael@0 178 -d ${dbDir} -v < ${SSL_REQ_FILE} >$resFile 2>&1
michael@0 179 ret=$?
michael@0 180 grep "ACCESS=OK" $resFile
michael@0 181 test $? -eq 0 -a $ret -eq 0
michael@0 182 ret=$?
michael@0 183 [ $ret -ne 0 ] && cat $resFile
michael@0 184 rm $resFile 2>/dev/null
michael@0 185
michael@0 186 html_msg $ret $value "${testname}. Client params: $cparam"\
michael@0 187 "produced a returncode of $ret, expected is $value"
michael@0 188 done < ${SSLAUTH_TMP}
michael@0 189 rm -f ${SSLAUTH_TMP} ${SSL_REQ_FILE}
michael@0 190
michael@0 191 html "</TABLE><BR>"
michael@0 192 }
michael@0 193
michael@0 194 ########################################################################
michael@0 195 # local shell function to perform SSL interoperability test with/out
michael@0 196 # revoked certs tests. Tests run against web server by using nss
michael@0 197 # test client
michael@0 198 # Params:
michael@0 199 # $1 - supported type of testing.
michael@0 200 # $2 - testing host
michael@0 201 # $3 - nss db location
michael@0 202 # No return value
michael@0 203 #
michael@0 204 ssl_iopr_crl_ext_server()
michael@0 205 {
michael@0 206 testType=$1
michael@0 207 host=$2
michael@0 208 dbDir=$3
michael@0 209
michael@0 210 setTestParam $testType
michael@0 211 if [ "`echo $testParam | grep NOCRL`" != "" ]; then
michael@0 212 echo "CRL SSL Client Tests of WebServerv($IOPR_HOSTADDR) excluded from " \
michael@0 213 "run by server configuration"
michael@0 214 return 0
michael@0 215 fi
michael@0 216
michael@0 217 html_head "CRL SSL Client Tests of WebServer($IOPR_HOSTADDR $BYPASS_STRING $NORM_EXT): $testDescription"
michael@0 218
michael@0 219 SSL_REQ_FILE=${TMP}/sslreq.dat.$$
michael@0 220 echo "GET $sslUrl HTTP/1.0" > $SSL_REQ_FILE
michael@0 221 echo >> $SSL_REQ_FILE
michael@0 222
michael@0 223 SSLAUTH_TMP=${TMP}/authin.tl.tmp
michael@0 224 grep -v "^#" ${SSLAUTH} | grep -- "-r_-r_-r_-r" | grep -v bogus | \
michael@0 225 grep -v none > ${SSLAUTH_TMP}
michael@0 226
michael@0 227 while read ecc value sparam _cparam testname; do
michael@0 228 [ -z "$ecc" -o "$ecc" = "#" -o "$ecc" = "ECC" ] && continue;
michael@0 229
michael@0 230 rev_modvalue=254
michael@0 231 for testUser in $SslClntValidCertName $SslClntRevokedCertName; do
michael@0 232 cparam=`echo $_cparam | sed -e 's;_; ;g' -e "s/TestUser/$testUser/g" `
michael@0 233
michael@0 234 echo "tstclnt -p ${sslPort} -h ${host} ${CLIEN_OPTIONS} \\"
michael@0 235 echo " -f -d ${dbDir} -v ${cparam} < ${SSL_REQ_FILE}"
michael@0 236 resFile=${TMP}/$HOST.tmp.$$
michael@0 237 rm -f $resFile 2>/dev/null
michael@0 238 ${BINDIR}/tstclnt -p ${sslPort} -h ${host} ${CLIEN_OPTIONS} -f ${cparam} \
michael@0 239 -d ${dbDir} -v < ${SSL_REQ_FILE} \
michael@0 240 > $resFile 2>&1
michael@0 241 ret=$?
michael@0 242 grep "ACCESS=OK" $resFile
michael@0 243 test $? -eq 0 -a $ret -eq 0
michael@0 244 ret=$?
michael@0 245 [ $ret -ne 0 ] && ret=$rev_modvalue;
michael@0 246 [ $ret -ne 0 ] && cat $resFile
michael@0 247 rm -f $resFile 2>/dev/null
michael@0 248
michael@0 249 if [ "`echo $SslClntRevokedCertName | grep $testUser`" != "" ]; then
michael@0 250 modvalue=$rev_modvalue
michael@0 251 testAddMsg="revoked"
michael@0 252 else
michael@0 253 testAddMsg="not revoked"
michael@0 254 modvalue=$value
michael@0 255 fi
michael@0 256 html_msg $ret $modvalue "${testname} (cert ${testUser} - $testAddMsg)" \
michael@0 257 "produced a returncode of $ret, expected is $modvalue"
michael@0 258 done
michael@0 259 done < ${SSLAUTH_TMP}
michael@0 260 rm -f ${SSLAUTH_TMP} ${SSL_REQ_FILE}
michael@0 261
michael@0 262 html "</TABLE><BR>"
michael@0 263 }
michael@0 264
michael@0 265
michael@0 266 ########################################################################
michael@0 267 # local shell function to perform SSL Cipher Coverage tests of nss server
michael@0 268 # by invoking remote test client on web server side.
michael@0 269 # Invoked only if reverse testing is supported by web server.
michael@0 270 # Params:
michael@0 271 # $1 - remote web server host
michael@0 272 # $2 - open port to connect to invoke CGI script
michael@0 273 # $3 - host where selfserv is running(name of the host nss tests
michael@0 274 # are running)
michael@0 275 # $4 - port where selfserv is running
michael@0 276 # $5 - selfserv nss db location
michael@0 277 # No return value
michael@0 278 #
michael@0 279 ssl_iopr_cov_ext_client()
michael@0 280 {
michael@0 281 host=$1
michael@0 282 port=$2
michael@0 283 sslHost=$3
michael@0 284 sslPort=$4
michael@0 285 serDbDir=$5
michael@0 286
michael@0 287 html_head "SSL Cipher Coverage of SelfServ $IOPR_HOSTADDR. $BYPASS_STRING $NORM_EXT"
michael@0 288
michael@0 289 setValidCert
michael@0 290 ret=$?
michael@0 291 if [ $res -ne 0 ]; then
michael@0 292 html_failed "Fail to find valid test cert(ws: $host)"
michael@0 293 return $ret
michael@0 294 fi
michael@0 295
michael@0 296 # P_R_SERVERDIR switch require for selfserv to work.
michael@0 297 # Will be restored after test
michael@0 298 OR_P_R_SERVERDIR=$P_R_SERVERDIR
michael@0 299 P_R_SERVERDIR=$serDbDir
michael@0 300 OR_P_R_CLIENTDIR=$P_R_CLIENTDIR
michael@0 301 P_R_CLIENTDIR=$serDbDir
michael@0 302 testname=""
michael@0 303 sparam="-vvvc ABCDEFcdefgijklmnvyz"
michael@0 304 # Launch the server
michael@0 305 start_selfserv
michael@0 306
michael@0 307 while read ecc tls param cipher therest; do
michael@0 308 [ -z "$ecc" -o "$ecc" = "#" -o "$ecc" = "ECC" ] && continue;
michael@0 309 echo "============= Beginning of the test ===================="
michael@0 310 echo
michael@0 311
michael@0 312 is_selfserv_alive
michael@0 313
michael@0 314 TEST_IN=${TMP}/${HOST}_IN.tmp.$$
michael@0 315 TEST_OUT=${TMP}/$HOST.tmp.$$
michael@0 316 rm -f $TEST_IN $TEST_OUT 2>/dev/null
michael@0 317
michael@0 318 echo "GET $reverseRunCGIScript?host=$sslHost&port=$sslPort&cert=$testUser&cipher=$cipher HTTP/1.0" > $TEST_IN
michael@0 319 echo >> $TEST_IN
michael@0 320
michael@0 321 echo "------- Request ----------------------"
michael@0 322 cat $TEST_IN
michael@0 323 echo "------- Command ----------------------"
michael@0 324 echo tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 325 -h $host \< $TEST_IN \>\> $TEST_OUT
michael@0 326
michael@0 327 ${BINDIR}/tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 328 -h $host <$TEST_IN > $TEST_OUT
michael@0 329
michael@0 330 echo "------- Server output Begin ----------"
michael@0 331 cat $TEST_OUT
michael@0 332 echo "------- Server output End ----------"
michael@0 333
michael@0 334 echo "Checking for errors in log file..."
michael@0 335 grep "SCRIPT=OK" $TEST_OUT 2>&1 >/dev/null
michael@0 336 if [ $? -eq 0 ]; then
michael@0 337 grep "cipher is not supported" $TEST_OUT 2>&1 >/dev/null
michael@0 338 if [ $? -eq 0 ]; then
michael@0 339 echo "Skiping test: no support for the cipher $cipher on server side"
michael@0 340 continue
michael@0 341 fi
michael@0 342
michael@0 343 grep -i "SERVER ERROR:" $TEST_OUT
michael@0 344 ret=$?
michael@0 345 if [ $ret -eq 0 ]; then
michael@0 346 echo "Found problems. Reseting exit code to failure."
michael@0 347
michael@0 348 ret=1
michael@0 349 else
michael@0 350 ret=0
michael@0 351 fi
michael@0 352 else
michael@0 353 echo "Script was not executed. Reseting exit code to failure."
michael@0 354 ret=11
michael@0 355 fi
michael@0 356
michael@0 357 html_msg $ret 0 "Test ${cipher}. Server params: $sparam " \
michael@0 358 " produced a returncode of $ret, expected is 0"
michael@0 359 rm -f $TEST_OUT $TEST_IN 2>&1 > /dev/null
michael@0 360 done < ${SSLCOV}
michael@0 361 kill_selfserv
michael@0 362
michael@0 363 P_R_SERVERDIR=$OR_P_R_SERVERDIR
michael@0 364 P_R_CLIENTDIR=$OR_P_R_CLIENTDIR
michael@0 365
michael@0 366 rm -f ${TEST_IN} ${TEST_OUT}
michael@0 367 html "</TABLE><BR>"
michael@0 368 }
michael@0 369
michael@0 370 ########################################################################
michael@0 371 # local shell function to perform SSL Authentication tests of nss server
michael@0 372 # by invoking remove test client on web server side
michael@0 373 # Invoked only if reverse testing is supported by web server.
michael@0 374 # Params:
michael@0 375 # $1 - remote web server host
michael@0 376 # $2 - open port to connect to invoke CGI script
michael@0 377 # $3 - host where selfserv is running(name of the host nss tests
michael@0 378 # are running)
michael@0 379 # $4 - port where selfserv is running
michael@0 380 # $5 - selfserv nss db location
michael@0 381 # No return value
michael@0 382 #
michael@0 383 ssl_iopr_auth_ext_client()
michael@0 384 {
michael@0 385 host=$1
michael@0 386 port=$2
michael@0 387 sslHost=$3
michael@0 388 sslPort=$4
michael@0 389 serDbDir=$5
michael@0 390
michael@0 391 html_head "SSL Client Authentication with Selfserv from $IOPR_HOSTADDR. $BYPASS_STRING $NORM_EXT"
michael@0 392
michael@0 393 setValidCert
michael@0 394 ret=$?
michael@0 395 if [ $res -ne 0 ]; then
michael@0 396 html_failed "Fail to find valid test cert(ws: $host)"
michael@0 397 return $ret
michael@0 398 fi
michael@0 399
michael@0 400 OR_P_R_SERVERDIR=$P_R_SERVERDIR
michael@0 401 P_R_SERVERDIR=${serDbDir}
michael@0 402 OR_P_R_CLIENTDIR=$P_R_CLIENTDIR
michael@0 403 P_R_CLIENTDIR=${serDbDir}
michael@0 404
michael@0 405 SSLAUTH_TMP=${TMP}/authin.tl.tmp
michael@0 406
michael@0 407 grep -v "^#" $SSLAUTH | grep "\s*0\s*" > ${SSLAUTH_TMP}
michael@0 408
michael@0 409 while read ecc value sparam cparam testname; do
michael@0 410 [ -z "$ecc" -o "$ecc" = "#" -o "$ecc" = "ECC" ] && continue;
michael@0 411
michael@0 412 echo "Server params: $sparam"
michael@0 413 sparam=$sparam" -vvvc ABCDEFcdefgijklmnvyz"
michael@0 414 start_selfserv
michael@0 415
michael@0 416 TEST_IN=${TMP}/$HOST_IN.tmp.$$
michael@0 417 TEST_OUT=${TMP}/$HOST.tmp.$$
michael@0 418 rm -f $TEST_IN $TEST_OUT 2>/dev/null
michael@0 419
michael@0 420 echo "GET $reverseRunCGIScript?host=$sslHost&port=$sslPort&cert=$testUser HTTP/1.0" > $TEST_IN
michael@0 421 echo >> $TEST_IN
michael@0 422
michael@0 423 echo "------- Request ----------------------"
michael@0 424 cat $TEST_IN
michael@0 425 echo "------- Command ----------------------"
michael@0 426 echo tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 427 -h $host \< $TEST_IN \>\> $TEST_OUT
michael@0 428
michael@0 429 ${BINDIR}/tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 430 -h $host <$TEST_IN > $TEST_OUT
michael@0 431
michael@0 432 echo "------- Server output Begin ----------"
michael@0 433 cat $TEST_OUT
michael@0 434 echo "------- Server output End ----------"
michael@0 435
michael@0 436 echo "Checking for errors in log file..."
michael@0 437 grep "SCRIPT=OK" $TEST_OUT 2>&1 >/dev/null
michael@0 438 if [ $? -eq 0 ]; then
michael@0 439 echo "Checking for error in log file..."
michael@0 440 grep -i "SERVER ERROR:" $TEST_OUT
michael@0 441 ret=$?
michael@0 442 if [ $ret -eq 0 ]; then
michael@0 443 echo "Found problems. Reseting exit code to failure."
michael@0 444 ret=1
michael@0 445 else
michael@0 446 ret=0
michael@0 447 fi
michael@0 448 else
michael@0 449 echo "Script was not executed. Reseting exit code to failure."
michael@0 450 ret=11
michael@0 451 fi
michael@0 452
michael@0 453 html_msg $ret $value "${testname}. Server params: $sparam"\
michael@0 454 "produced a returncode of $ret, expected is $value"
michael@0 455 kill_selfserv
michael@0 456 rm -f $TEST_OUT $TEST_IN 2>&1 > /dev/null
michael@0 457 done < ${SSLAUTH_TMP}
michael@0 458
michael@0 459 P_R_SERVERDIR=$OR_P_R_SERVERDIR
michael@0 460 P_R_CLIENTDIR=$OR_P_R_CLIENTDIR
michael@0 461
michael@0 462 rm -f ${SSLAUTH_TMP} ${TEST_IN} ${TEST_OUT}
michael@0 463 html "</TABLE><BR>"
michael@0 464 }
michael@0 465
michael@0 466 #########################################################################
michael@0 467 # local shell function to perform SSL CRL testing of nss server
michael@0 468 # by invoking remote test client on web server side
michael@0 469 # Invoked only if reverse testing is supported by web server.
michael@0 470 # Params:
michael@0 471 # $1 - remote web server host
michael@0 472 # $2 - open port to connect to invoke CGI script
michael@0 473 # $3 - host where selfserv is running(name of the host nss tests
michael@0 474 # are running)
michael@0 475 # $4 - port where selfserv is running
michael@0 476 # $5 - selfserv nss db location
michael@0 477 # No return value
michael@0 478 #
michael@0 479 ssl_iopr_crl_ext_client()
michael@0 480 {
michael@0 481 host=$1
michael@0 482 port=$2
michael@0 483 sslHost=$3
michael@0 484 sslPort=$4
michael@0 485 serDbDir=$5
michael@0 486
michael@0 487 html_head "CRL SSL Selfserv Tests from $IOPR_HOSTADDR. $BYPASS_STRING $NORM_EXT"
michael@0 488
michael@0 489 OR_P_R_SERVERDIR=$P_R_SERVERDIR
michael@0 490 P_R_SERVERDIR=${serDbDir}
michael@0 491 OR_P_R_CLIENTDIR=$P_R_CLIENTDIR
michael@0 492 P_R_CLIENTDIR=$serDbDir
michael@0 493
michael@0 494 SSLAUTH_TMP=${TMP}/authin.tl.tmp
michael@0 495 grep -v "^#" $SSLAUTH | grep "\s*0\s*" > ${SSLAUTH_TMP}
michael@0 496
michael@0 497 while read ecc value sparam _cparam testname; do
michael@0 498 [ -z "$ecc" -o "$ecc" = "#" -o "$ecc" = "ECC" ] && continue;
michael@0 499 sparam="$sparam -vvvc ABCDEFcdefgijklmnvyz"
michael@0 500 start_selfserv
michael@0 501
michael@0 502 for testUser in $SslClntValidCertName $SslClntRevokedCertName; do
michael@0 503
michael@0 504 is_selfserv_alive
michael@0 505
michael@0 506 TEST_IN=${TMP}/${HOST}_IN.tmp.$$
michael@0 507 TEST_OUT=${TMP}/$HOST.tmp.$$
michael@0 508 rm -f $TEST_IN $TEST_OUT 2>/dev/null
michael@0 509
michael@0 510 echo "GET $reverseRunCGIScript?host=$sslHost&port=$sslPort&cert=$testUser HTTP/1.0" > $TEST_IN
michael@0 511 echo >> $TEST_IN
michael@0 512
michael@0 513 echo "------- Request ----------------------"
michael@0 514 cat $TEST_IN
michael@0 515 echo "------- Command ----------------------"
michael@0 516 echo tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 517 -h ${host} \< $TEST_IN \>\> $TEST_OUT
michael@0 518
michael@0 519 ${BINDIR}/tstclnt -d $serDbDir -v -w ${R_PWFILE} -o -p $port \
michael@0 520 -h ${host} <$TEST_IN > $TEST_OUT
michael@0 521 echo "------- Request ----------------------"
michael@0 522 cat $TEST_IN
michael@0 523 echo "------- Server output Begin ----------"
michael@0 524 cat $TEST_OUT
michael@0 525 echo "------- Server output End ----------"
michael@0 526
michael@0 527 echo "Checking for errors in log file..."
michael@0 528 grep "SCRIPT=OK" $TEST_OUT 2>&1 >/dev/null
michael@0 529 if [ $? -eq 0 ]; then
michael@0 530 grep -i "SERVER ERROR:" $TEST_OUT
michael@0 531 ret=$?
michael@0 532 if [ $ret -eq 0 ]; then
michael@0 533 echo "Found problems. Reseting exit code to failure."
michael@0 534 ret=1
michael@0 535 else
michael@0 536 ret=0
michael@0 537 fi
michael@0 538 else
michael@0 539 echo "Script was not executed. Reseting exit code to failure."
michael@0 540 ret=11
michael@0 541 fi
michael@0 542
michael@0 543 if [ "`echo $SslClntRevokedCertName | grep $testUser`" != "" ]; then
michael@0 544 modvalue=1
michael@0 545 testAddMsg="revoked"
michael@0 546 else
michael@0 547 testAddMsg="not revoked"
michael@0 548 modvalue=0
michael@0 549 fi
michael@0 550
michael@0 551 html_msg $ret $modvalue "${testname} (cert ${testUser} - $testAddMsg)" \
michael@0 552 "produced a returncode of $ret, expected is $modvalue(selfserv args: $sparam)"
michael@0 553 rm -f $TEST_OUT $TEST_IN 2>&1 > /dev/null
michael@0 554 done
michael@0 555 kill_selfserv
michael@0 556 done < ${SSLAUTH_TMP}
michael@0 557
michael@0 558 P_R_SERVERDIR=$OR_P_R_SERVERDIR
michael@0 559 P_R_CLIENTDIR=$OR_P_R_CLIENTDIR
michael@0 560
michael@0 561 rm -f ${SSLAUTH_TMP}
michael@0 562 html "</TABLE><BR>"
michael@0 563 }
michael@0 564
michael@0 565 #####################################################################
michael@0 566 # Initial point for running ssl test againt multiple hosts involved in
michael@0 567 # interoperability testing. Called from nss/tests/ssl/ssl.sh
michael@0 568 # It will only proceed with test run for a specific host if environment variable
michael@0 569 # IOPR_HOSTADDR_LIST was set, had the host name in the list
michael@0 570 # and all needed file were successfully downloaded and installed for the host.
michael@0 571 #
michael@0 572 # Returns 1 if interoperability testing is off, 0 otherwise.
michael@0 573 #
michael@0 574 ssl_iopr_run() {
michael@0 575 if [ "$IOPR" -ne 1 ]; then
michael@0 576 return 1
michael@0 577 fi
michael@0 578 cd ${CLIENTDIR}
michael@0 579
michael@0 580 ORIG_ECC_CERT=${NO_ECC_CERTS}
michael@0 581 NO_ECC_CERTS=1 # disable ECC for interoperability tests
michael@0 582
michael@0 583 NSS_SSL_ENABLE_RENEGOTIATION=u
michael@0 584 export NSS_SSL_ENABLE_RENEGOTIATION
michael@0 585
michael@0 586 num=1
michael@0 587 IOPR_HOST_PARAM=`echo "${IOPR_HOSTADDR_LIST} " | cut -f $num -d' '`
michael@0 588 while [ "$IOPR_HOST_PARAM" ]; do
michael@0 589 IOPR_HOSTADDR=`echo $IOPR_HOST_PARAM | cut -f 1 -d':'`
michael@0 590 IOPR_OPEN_PORT=`echo "$IOPR_HOST_PARAM:" | cut -f 2 -d':'`
michael@0 591 [ -z "$IOPR_OPEN_PORT" ] && IOPR_OPEN_PORT=443
michael@0 592
michael@0 593 . ${IOPR_CADIR}_${IOPR_HOSTADDR}/iopr_server.cfg
michael@0 594 RES=$?
michael@0 595
michael@0 596 if [ $RES -ne 0 -o X`echo "$wsFlags" | grep NOIOPR` != X ]; then
michael@0 597 num=`expr $num + 1`
michael@0 598 IOPR_HOST_PARAM=`echo "${IOPR_HOSTADDR_LIST} " | cut -f $num -d' '`
michael@0 599 continue
michael@0 600 fi
michael@0 601
michael@0 602 #=======================================================
michael@0 603 # Check if server is capable to run ssl tests
michael@0 604 #
michael@0 605 [ -z "`echo ${supportedTests_new} | grep -i ssl`" ] && continue;
michael@0 606
michael@0 607 # Testing directories defined by webserver.
michael@0 608 echo "Testing ssl interoperability.
michael@0 609 Client: local(tstclnt).
michael@0 610 Server: remote($IOPR_HOSTADDR:$IOPR_OPEN_PORT)"
michael@0 611
michael@0 612 for sslTestType in ${supportedTests_new}; do
michael@0 613 if [ -z "`echo $sslTestType | grep -i ssl`" ]; then
michael@0 614 continue
michael@0 615 fi
michael@0 616 ssl_iopr_cov_ext_server $sslTestType ${IOPR_HOSTADDR} \
michael@0 617 ${IOPR_SSL_CLIENTDIR}_${IOPR_HOSTADDR}
michael@0 618 ssl_iopr_auth_ext_server $sslTestType ${IOPR_HOSTADDR} \
michael@0 619 ${IOPR_SSL_CLIENTDIR}_${IOPR_HOSTADDR}
michael@0 620 ssl_iopr_crl_ext_server $sslTestType ${IOPR_HOSTADDR} \
michael@0 621 ${IOPR_SSL_CLIENTDIR}_${IOPR_HOSTADDR}
michael@0 622 done
michael@0 623
michael@0 624
michael@0 625 # Testing selfserv with client located at the webserver.
michael@0 626 echo "Testing ssl interoperability.
michael@0 627 Client: remote($IOPR_HOSTADDR:$PORT)
michael@0 628 Server: local(selfserv)"
michael@0 629 ssl_iopr_cov_ext_client ${IOPR_HOSTADDR} ${IOPR_OPEN_PORT} \
michael@0 630 ${HOSTADDR} ${PORT} ${R_IOPR_SSL_SERVERDIR}_${IOPR_HOSTADDR}
michael@0 631 ssl_iopr_auth_ext_client ${IOPR_HOSTADDR} ${IOPR_OPEN_PORT} \
michael@0 632 ${HOSTADDR} ${PORT} ${R_IOPR_SSL_SERVERDIR}_${IOPR_HOSTADDR}
michael@0 633 ssl_iopr_crl_ext_client ${IOPR_HOSTADDR} ${IOPR_OPEN_PORT} \
michael@0 634 ${HOSTADDR} ${PORT} ${R_IOPR_SSL_SERVERDIR}_${IOPR_HOSTADDR}
michael@0 635 echo "================================================"
michael@0 636 echo "Done testing interoperability with $IOPR_HOSTADDR"
michael@0 637 num=`expr $num + 1`
michael@0 638 IOPR_HOST_PARAM=`echo "${IOPR_HOSTADDR_LIST} " | cut -f $num -d' '`
michael@0 639 done
michael@0 640 NO_ECC_CERTS=${ORIG_ECC_CERTS}
michael@0 641 return 0
michael@0 642 }
michael@0 643

mercurial