3
# The contents of this file are subject to the Mozilla Public
4
# License Version 1.1 (the "License"); you may not use this file
5
# except in compliance with the License. You may obtain a copy of
6
# the License at http://www.mozilla.org/MPL/
8
# Software distributed under the License is distributed on an "AS
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
# implied. See the License for the specific language governing
11
# rights and limitations under the License.
13
# The Original Code is the Netscape security libraries.
15
# The Initial Developer of the Original Code is Netscape
16
# Communications Corporation. Portions created by Netscape are
17
# Copyright (C) 1994-2000 Netscape Communications Corporation. All
20
# Portions created by Sun Microsystems, Inc. are Copyright (C) 2003
21
# Sun Microsystems, Inc. All Rights Reserved.
24
# Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories
26
# Alternatively, the contents of this file may be used under the
27
# terms of the GNU General Public License Version 2 or later (the
28
# "GPL"), in which case the provisions of the GPL are applicable
29
# instead of those above. If you wish to allow use of your
30
# version of this file only under the terms of the GPL and not to
31
# allow others to use your version of this file under the MPL,
32
# indicate your decision by deleting the provisions above and
33
# replace them with the notice and other provisions required by
34
# the GPL. If you do not delete the provisions above, a recipient
35
# may use your version of this file under either the MPL or the
39
########################################################################
41
# mozilla/security/nss/tests/ssl/ssl.sh
43
# Script to test NSS SSL
45
# needs to work on all Unix and Windows platforms
49
# FIXME ... known problems, search for this string
50
# NOTE .... unexpected behavior
52
########################################################################
54
############################## ssl_init ################################
55
# local shell function to initialize this script
56
########################################################################
59
SCRIPTNAME=ssl.sh # sourced - $0 would point to all.sh
61
if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
62
CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
65
if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
69
if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here
74
echo "$SCRIPTNAME: SSL tests ==============================="
76
grep "SUCCESS: SSL passed" $CERT_LOG_FILE >/dev/null || {
77
html_head "SSL Test failure"
78
Exit 8 "Fatal - SSL of cert.sh needs to pass first"
84
SSLCOV=${QADIR}/ssl/sslcov.txt
85
SSLAUTH=${QADIR}/ssl/sslauth.txt
86
SSLSTRESS=${QADIR}/ssl/sslstress.txt
87
REQUEST_FILE=${QADIR}/ssl/sslreq.txt
90
SERVEROUTFILE=${TMP}/tests_server.$$
91
SERVERPID=${TMP}/tests_pid.$$
93
R_SERVERPID=../tests_pid.$$
95
TEMPFILES="$TMPFILES ${SERVEROUTFILE} ${SERVERPID}"
97
fileout=0 #FIXME, looks like all.sh tried to turn this on but actually didn't
99
#verbose="-v" #FIXME - see where this is usefull
101
USER_NICKNAME=TestUser
107
########################### is_selfserv_alive ##########################
108
# local shell function to exit with a fatal error if selfserver is not
110
########################################################################
113
if [ ! -f "${SERVERPID}" ]; then
114
echo "$SCRIPTNAME: Error - selfserv PID file ${SERVERPID} doesn't exist"
116
if [ ! -f "${SERVERPID}" ]; then
117
Exit 9 "Fatal - selfserv pid file ${SERVERPID} does not exist"
120
PID=`cat ${SERVERPID}`
121
#if [ "${OS_ARCH}" = "Linux" ]; then
122
kill -0 $PID >/dev/null 2>/dev/null || Exit 10 "Fatal - selfserv process not detectable"
124
#$PS -e | grep $PID >/dev/null || \
125
#Exit 10 "Fatal - selfserv process not detectable"
129
########################### wait_for_selfserv ##########################
130
# local shell function to wait until selfserver is running and initialized
131
########################################################################
134
echo "tstclnt -p ${PORT} -h ${HOSTADDR} -q "
135
echo " -d ${P_R_CLIENTDIR} < ${REQUEST_FILE} \\"
136
#echo "tstclnt -q started at `date`"
137
tstclnt -p ${PORT} -h ${HOSTADDR} -q -d ${P_R_CLIENTDIR} < ${REQUEST_FILE}
138
if [ $? -ne 0 ]; then
139
html_failed "<TR><TD> Wait for Server "
140
echo "RETRY: tstclnt -p ${PORT} -h ${HOSTADDR} -q \\"
141
echo " -d ${P_R_CLIENTDIR} < ${REQUEST_FILE}"
142
tstclnt -p ${PORT} -h ${HOSTADDR} -q -d ${P_R_CLIENTDIR} < ${REQUEST_FILE}
143
elif [ sparam = "-c ABCDEFGHIJKLMNOPQRSTabcdefghijklmnvy" ] ; then # "$1" = "cov" ] ; then
144
html_passed "<TR><TD> Wait for Server"
149
########################### kill_selfserv ##############################
150
# local shell function to kill the selfserver after the tests are done
151
########################################################################
154
${KILL} `cat ${SERVERPID}`
155
wait `cat ${SERVERPID}`
156
if [ ${fileout} -eq 1 ]; then
159
# On Linux selfserv needs up to 30 seconds to fully die and free
160
# the port. Wait until the port is free. (Bug 129701)
161
if [ "${OS_ARCH}" = "Linux" ]; then
162
until selfserv -b -p ${PORT} 2>/dev/null; do
169
########################### start_selfserv #############################
170
# local shell function to start the selfserver with the parameters required
171
# for this test and log information (parameters, start time)
172
# also: wait until the server is up and running
173
########################################################################
176
if [ -n "$testname" ] ; then
177
echo "$SCRIPTNAME: $testname ----"
179
sparam=`echo $sparam | sed -e 's;_; ;g'`
180
echo "selfserv -D -p ${PORT} -d ${P_R_SERVERDIR} -n ${HOSTADDR} \\"
181
echo " -e ${HOSTADDR}-ec \\"
182
echo " -w nss ${sparam} -i ${R_SERVERPID} $verbose &"
183
echo "selfserv started at `date`"
184
if [ ${fileout} -eq 1 ]; then
185
selfserv -D -p ${PORT} -d ${P_R_SERVERDIR} -n ${HOSTADDR} \
187
-w nss ${sparam} -i ${R_SERVERPID} $verbose \
188
> ${SERVEROUTFILE} 2>&1 &
190
selfserv -D -p ${PORT} -d ${P_R_SERVERDIR} -n ${HOSTADDR} \
192
-w nss ${sparam} -i ${R_SERVERPID} $verbose &
197
############################## ssl_cov #################################
198
# local shell function to perform SSL Cipher Coverage tests
199
########################################################################
202
html_head "SSL Cipher Coverage $NORM_EXT"
205
sparam="-c ABCDEFGHIJKLMNOPQRSTabcdefghijklmnvyz"
206
start_selfserv # Launch the server
210
while read tls param testname
212
p=`echo "$testname" | sed -e "s/ .*//"` #sonmi, only run extended test on SSL3 and TLS
214
if [ "$p" = "SSL2" -a "$NORM_EXT" = "Extended test" ] ; then
215
echo "$SCRIPTNAME: skipping $testname for $NORM_EXT"
216
elif [ "$tls" != "#" ] ; then
217
echo "$SCRIPTNAME: running $testname ----------------------------"
219
if [ $tls = "TLS" ]; then
224
echo "tstclnt -p ${PORT} -h ${HOSTADDR} -c ${param} ${TLS_FLAG} \\"
225
echo " -f -d ${P_R_CLIENTDIR} < ${REQUEST_FILE}"
227
rm ${TMP}/$HOST.tmp.$$ 2>/dev/null
228
tstclnt -p ${PORT} -h ${HOSTADDR} -c ${param} ${TLS_FLAG} -f \
229
-d ${P_R_CLIENTDIR} < ${REQUEST_FILE} \
230
>${TMP}/$HOST.tmp.$$ 2>&1
232
cat ${TMP}/$HOST.tmp.$$
233
rm ${TMP}/$HOST.tmp.$$ 2>/dev/null
234
html_msg $ret 0 "${testname}"
242
############################## ssl_auth ################################
243
# local shell function to perform SSL Client Authentication tests
244
########################################################################
247
html_head "SSL Client Authentication $NORM_EXT"
249
while read value sparam cparam testname
251
if [ $value != "#" ]; then
252
cparam=`echo $cparam | sed -e 's;_; ;g' -e "s/TestUser/$USER_NICKNAME/g" `
255
echo "tstclnt -p ${PORT} -h ${HOSTADDR} -f -d ${P_R_CLIENTDIR} \\"
256
echo " ${cparam} < ${REQUEST_FILE}"
257
rm ${TMP}/$HOST.tmp.$$ 2>/dev/null
258
tstclnt -p ${PORT} -h ${HOSTADDR} -f ${cparam} \
259
-d ${P_R_CLIENTDIR} < ${REQUEST_FILE} \
260
>${TMP}/$HOST.tmp.$$ 2>&1
262
cat ${TMP}/$HOST.tmp.$$
263
rm ${TMP}/$HOST.tmp.$$ 2>/dev/null
265
html_msg $ret $value "${testname}" \
266
"produced a returncode of $ret, expected is $value"
275
############################## ssl_stress ##############################
276
# local shell function to perform SSL stress test
277
########################################################################
280
html_head "SSL Stress Test $NORM_EXT"
282
while read value sparam cparam testname
284
p=`echo "$testname" | sed -e "s/Stress //" -e "s/ .*//"` #sonmi, only run extended test on SSL3 and TLS
285
if [ "$p" = "SSL2" -a "$NORM_EXT" = "Extended test" ] ; then
286
echo "$SCRIPTNAME: skipping $testname for $NORM_EXT"
287
elif [ $value != "#" ]; then
288
cparam=`echo $cparam | sed -e 's;_; ;g'`
290
if [ `uname -n` = "sjsu" ] ; then
291
echo "debugging disapering selfserv... ps -ef | grep selfserv"
292
ps -ef | grep selfserv
295
echo "strsclnt -q -p ${PORT} -d ${P_R_CLIENTDIR} -w nss $cparam \\"
296
echo " $verbose ${HOSTADDR}"
297
echo "strsclnt started at `date`"
298
strsclnt -q -p ${PORT} -d ${P_R_CLIENTDIR} -w nss $cparam \
301
echo "strsclnt completed at `date`"
302
html_msg $ret $value "${testname}"
303
if [ `uname -n` = "sjsu" ] ; then
304
echo "debugging disapering selfserv... ps -ef | grep selfserv"
305
ps -ef | grep selfserv
315
############################## ssl_cleanup #############################
316
# local shell function to finish this script (no exit since it might be
318
########################################################################
321
rm $SERVERPID 2>/dev/null
326
################## main #################################################
328
#this script may be sourced from the distributed stress test - in this case do nothing...
330
if [ -z "$DO_REM_ST" -a -z "$DO_DIST_ST" ] ; then
336
SERVERDIR=$EXT_SERVERDIR
337
CLIENTDIR=$EXT_CLIENTDIR
338
R_SERVERDIR=$R_EXT_SERVERDIR
339
R_CLIENTDIR=$R_EXT_CLIENTDIR
340
P_R_SERVERDIR=$P_R_EXT_SERVERDIR
341
P_R_CLIENTDIR=$P_R_EXT_CLIENTDIR
342
USER_NICKNAME=ExtendedSSLUser
343
NORM_EXT="Extended test"