3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is the Netscape security libraries.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1994-2000
21 # the Initial Developer. All Rights Reserved.
24 # Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories
25 # Slavomir Katuscak <slavomir.katuscak@sun.com>, Sun Microsystems
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 ########################################################################
43 # mozilla/security/nss/tests/cert/rcert.sh
45 # Certificate generating and handeling for NSS QA, can be included
46 # multiple times from all.sh and the individual scripts
48 # needs to work on all Unix and Windows platforms
50 # included from (don't expect this to be up to date)
51 # --------------------------------------------------
59 # FIXME ... known problems, search for this string
60 # NOTE .... unexpected behavior
62 # FIXME - Netscape - NSS
63 ########################################################################
65 ############################## cert_init ###############################
66 # local shell function to initialize this script
67 ########################################################################
71 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
72 CLEANUP
="${SCRIPTNAME}" # cleaning this script will do it
74 if [ -z "${INIT_SOURCED}" ] ; then
78 if [ -z "${IOPR_CERT_SOURCED}" ]; then
79 . ..
/iopr
/cert_iopr.sh
82 CRL_GRP_DATE
=`date "+%Y%m%d%H%M%SZ"`
83 if [ -n "$NSS_ENABLE_ECC" ] ; then
84 html_head
"Certutil and Crlutil Tests with ECC"
86 html_head
"Certutil and Crlutil Tests"
89 LIBDIR
="${DIST}/${OBJDIR}/lib"
91 ROOTCERTSFILE
=`ls -1 ${LIBDIR}/*nssckbi* | head -1`
92 if [ ! "${ROOTCERTSFILE}" ] ; then
93 html_failed
"<TR><TD>Looking for root certs module."
94 cert_log
"ERROR: Root certs module not found."
95 Exit
5 "Fatal - Root certs module not found."
97 html_passed
"<TR><TD>Looking for root certs module."
100 ################## Generate noise for our CA cert. ######################
101 # NOTE: these keys are only suitable for testing, as this whole thing
102 # bypasses the entropy gathering. Don't use this method to generate
103 # keys and certs for product use or deployment.
105 ps
-efl > ${NOISE_FILE} 2>&1
106 ps aux
>> ${NOISE_FILE} 2>&1
111 cert_log
() ###################### write the cert_status file
113 echo "$SCRIPTNAME $*"
114 echo $
* >>${CERT_LOG_FILE}
117 ################################ noise ##################################
118 # Generate noise for our certs
120 # NOTE: these keys are only suitable for testing, as this whole thing bypasses
121 # the entropy gathering. Don't use this method to generate keys and certs for
122 # product use or deployment.
123 #########################################################################
126 #netstat >> ${NOISE_FILE} 2>&1
127 date >> ${NOISE_FILE} 2>&1
130 ################################ certu #################################
131 # local shell function to call certutil, also: writes action and options to
132 # stdout, sets variable RET and writes results to the html file results
133 ########################################################################
136 echo "$SCRIPTNAME: ${CU_ACTION} --------------------------"
138 if [ -n "${CU_SUBJECT}" ]; then
139 #the subject of the cert contains blanks, and the shell
140 #will strip the quotes off the string, if called otherwise...
141 echo "certutil -s \"${CU_SUBJECT}\" $*"
142 certutil
-s "${CU_SUBJECT}" $
*
150 if [ "$RET" -ne 0 ]; then
152 html_failed
"<TR><TD>${CU_ACTION} ($RET) "
153 cert_log
"ERROR: ${CU_ACTION} failed $RET"
155 html_passed
"<TR><TD>${CU_ACTION}"
161 ################################ crlu #################################
162 # local shell function to call crlutil, also: writes action and options to
163 # stdout, sets variable RET and writes results to the html file results
164 ########################################################################
167 echo "$SCRIPTNAME: ${CU_ACTION} --------------------------"
173 if [ "$RET" -ne 0 ]; then
175 html_failed
"<TR><TD>${CU_ACTION} ($RET) "
176 cert_log
"ERROR: ${CU_ACTION} failed $RET"
178 html_passed
"<TR><TD>${CU_ACTION}"
186 echo "$SCRIPTNAME: ${CU_ACTION} --------------------------"
192 if [ "$RET" -ne 0 ]; then
194 html_failed
"<TR><TD>${CU_ACTION} ($RET) "
195 cert_log
"ERROR: ${CU_ACTION} failed $RET"
197 html_passed
"<TR><TD>${CU_ACTION}"
203 ############################# cert_init_cert ##########################
204 # local shell function to initialize creation of client and server certs
205 ########################################################################
213 if [ ! -d "${CERTDIR}" ]; then
214 mkdir
-p "${CERTDIR}"
216 echo "$SCRIPTNAME: WARNING - ${CERTDIR} exists"
221 PROFILEDIR
=`cd ${CERTDIR}; pwd`
222 if [ -n "${MULTIACCESS_DBM}" ]; then
223 PROFILEDIR
="multiaccess:${DOMAIN}"
229 ############################# hw_acc #################################
230 # local shell function to add hw accelerator modules to the db
231 ########################################################################
236 if [ -n "$O_HWACC" -a "$O_HWACC" = ON
-a -z "$USE_64" ] ; then
237 echo "creating $CERTNAME s cert with hwaccelerator..."
238 #case $ACCELERATOR in
241 echo "modutil -add rainbow -libfile /usr/lib/libcryptoki22.so "
242 echo " -dbdir ${PROFILEDIR} 2>&1 "
243 echo | modutil
-add rainbow
-libfile /usr
/lib
/libcryptoki22.so \
244 -dbdir ${PROFILEDIR} 2>&1
245 if [ "$?" -ne 0 ]; then
246 echo "modutil -add rainbow failed in `pwd`"
248 HW_ACC_ERR
="modutil -add rainbow"
251 echo "modutil -add ncipher "
252 echo " -libfile /opt/nfast/toolkits/pkcs11/libcknfast.so "
253 echo " -dbdir ${PROFILEDIR} 2>&1 "
254 echo | modutil
-add ncipher \
255 -libfile /opt
/nfast
/toolkits
/pkcs11
/libcknfast.so \
256 -dbdir ${PROFILEDIR} 2>&1
257 if [ "$?" -ne 0 ]; then
258 echo "modutil -add ncipher failed in `pwd`"
259 HW_ACC_RET
=`expr $HW_ACC_RET + 2`
260 HW_ACC_ERR
="$HW_ACC_ERR,modutil -add ncipher"
262 if [ "$HW_ACC_RET" -ne 0 ]; then
263 html_failed
"<TR><TD>Adding HW accelerators to certDB for ${CERTNAME} ($HW_ACC_RET) "
265 html_passed
"<TR><TD>Adding HW accelerators to certDB for ${CERTNAME}"
272 ############################# cert_create_cert #########################
273 # local shell function to create client certs
274 # initialize DB, import
277 ########################################################################
280 cert_init_cert
"$1" "$2" "$3" "$4"
282 CU_ACTION
="Initializing ${CERTNAME}'s Cert DB"
283 certu
-N -d "${PROFILEDIR}" -f "${R_PWFILE}" 2>&1
284 if [ "$RET" -ne 0 ]; then
288 CU_ACTION
="Loading root cert module to ${CERTNAME}'s Cert DB"
289 modu
-add "RootCerts" -libfile "${ROOTCERTSFILE}" -dbdir "${PROFILEDIR}" 2>&1
290 if [ "$RET" -ne 0 ]; then
296 CU_ACTION
="Import Root CA for $CERTNAME"
297 certu
-A -n "TestCA" -t "TC,TC,TC" -f "${R_PWFILE}" -d "${PROFILEDIR}" \
298 -i "${R_CADIR}/root.cert" 2>&1
299 if [ "$RET" -ne 0 ]; then
303 if [ -n "$NSS_ENABLE_ECC" ] ; then
304 CU_ACTION
="Import EC Root CA for $CERTNAME"
305 certu
-A -n "TestCA-ec" -t "TC,TC,TC" -f "${R_PWFILE}" \
306 -d "${PROFILEDIR}" -i "${R_CADIR}/ecroot.cert" 2>&1
307 if [ "$RET" -ne 0 ]; then
316 ############################# cert_add_cert ############################
317 # local shell function to add client certs to an existing CERT DB
322 ########################################################################
325 CU_ACTION
="Generate Cert Request for $CERTNAME"
326 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
327 certu
-R -d "${PROFILEDIR}" -f "${R_PWFILE}" -z "${R_NOISE_FILE}" -o req
2>&1
328 if [ "$RET" -ne 0 ]; then
332 CU_ACTION
="Sign ${CERTNAME}'s Request"
333 certu
-C -c "TestCA" -m "$CERTSERIAL" -v 60 -d "${P_R_CADIR}" \
334 -i req
-o "${CERTNAME}.cert" -f "${R_PWFILE}" "$1" 2>&1
335 if [ "$RET" -ne 0 ]; then
339 CU_ACTION
="Import $CERTNAME's Cert"
340 certu
-A -n "$CERTNAME" -t "u,u,u" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
341 -i "${CERTNAME}.cert" 2>&1
342 if [ "$RET" -ne 0 ]; then
346 cert_log
"SUCCESS: $CERTNAME's Cert Created"
349 # Generate and add EC cert
351 if [ -n "$NSS_ENABLE_ECC" ] ; then
353 CU_ACTION
="Generate EC Cert Request for $CERTNAME"
354 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ec@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
355 certu
-R -k ec
-q "${CURVE}" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
356 -z "${R_NOISE_FILE}" -o req
2>&1
357 if [ "$RET" -ne 0 ]; then
361 CU_ACTION
="Sign ${CERTNAME}'s EC Request"
362 certu
-C -c "TestCA-ec" -m "$CERTSERIAL" -v 60 -d "${P_R_CADIR}" \
363 -i req
-o "${CERTNAME}-ec.cert" -f "${R_PWFILE}" "$1" 2>&1
364 if [ "$RET" -ne 0 ]; then
368 CU_ACTION
="Import $CERTNAME's EC Cert"
369 certu
-A -n "${CERTNAME}-ec" -t "u,u,u" -d "${PROFILEDIR}" \
370 -f "${R_PWFILE}" -i "${CERTNAME}-ec.cert" 2>&1
371 if [ "$RET" -ne 0 ]; then
374 cert_log
"SUCCESS: $CERTNAME's EC Cert Created"
376 # Generate EC certificate signed with RSA
377 CU_ACTION
="Generate mixed EC Cert Request for $CERTNAME"
378 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ecmixed@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
379 certu
-R -k ec
-q "${CURVE}" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
380 -z "${R_NOISE_FILE}" -o req
2>&1
381 if [ "$RET" -ne 0 ]; then
385 CU_ACTION
="Sign ${CERTNAME}'s EC Request with RSA"
386 # Avoid conflicting serial numbers with TestCA issuer by keeping
387 # this set far away. A smaller number risks colliding with the
388 # extended ssl user certificates.
389 NEWSERIAL
=`expr ${CERTSERIAL} + 10000`
390 certu
-C -c "TestCA" -m "$NEWSERIAL" -v 60 -d "${P_R_CADIR}" \
391 -i req
-o "${CERTNAME}-ecmixed.cert" -f "${R_PWFILE}" "$1" 2>&1
392 if [ "$RET" -ne 0 ]; then
396 CU_ACTION
="Import $CERTNAME's mixed EC Cert"
397 certu
-A -n "${CERTNAME}-ecmixed" -t "u,u,u" -d "${PROFILEDIR}" \
398 -f "${R_PWFILE}" -i "${CERTNAME}-ecmixed.cert" 2>&1
399 if [ "$RET" -ne 0 ]; then
402 cert_log
"SUCCESS: $CERTNAME's mixed EC Cert Created"
408 ################################# cert_all_CA ################################
409 # local shell function to build the additional Temp. Certificate Authority (CA)
410 # used for the "real life" ssl test with 2 different CA's in the
411 # client and in teh server's dir
412 ##########################################################################
417 ALL_CU_SUBJECT
="CN=NSS Test CA, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
418 cert_CA
$CADIR TestCA
-x "CTu,CTu,CTu" ${D_CA} "1"
420 ALL_CU_SUBJECT
="CN=NSS Server Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
421 cert_CA
$SERVER_CADIR serverCA
-x "Cu,Cu,Cu" ${D_SERVER_CA} "2"
422 ALL_CU_SUBJECT
="CN=NSS Chain1 Server Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
423 cert_CA
$SERVER_CADIR chain-1-serverCA
"-c serverCA" "u,u,u" ${D_SERVER_CA} "3"
424 ALL_CU_SUBJECT
="CN=NSS Chain2 Server Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
425 cert_CA
$SERVER_CADIR chain-2-serverCA
"-c chain-1-serverCA" "u,u,u" ${D_SERVER_CA} "4"
429 ALL_CU_SUBJECT
="CN=NSS Client Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
430 cert_CA
$CLIENT_CADIR clientCA
-x "Tu,Cu,Cu" ${D_CLIENT_CA} "5"
431 ALL_CU_SUBJECT
="CN=NSS Chain1 Client Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
432 cert_CA
$CLIENT_CADIR chain-1-clientCA
"-c clientCA" "u,u,u" ${D_CLIENT_CA} "6"
433 ALL_CU_SUBJECT
="CN=NSS Chain2 Client Test CA, O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
434 cert_CA
$CLIENT_CADIR chain-2-clientCA
"-c chain-1-clientCA" "u,u,u" ${D_CLIENT_CA} "7"
436 rm $CLIENT_CADIR/root.cert
$SERVER_CADIR/root.cert
438 # root.cert in $CLIENT_CADIR and in $SERVER_CADIR is one of the last
441 if [ -n "$NSS_ENABLE_ECC" ] ; then
443 # Create EC version of TestCA
445 ALL_CU_SUBJECT
="CN=NSS Test CA (ECC), O=BOGUS NSS, L=Mountain View, ST=California, C=US"
446 cert_ec_CA
$CADIR TestCA-ec
-x "CTu,CTu,CTu" ${D_CA} "1" ${CA_CURVE}
448 # Create EC versions of the intermediate CA certs
449 ALL_CU_SUBJECT
="CN=NSS Server Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
450 cert_ec_CA
$SERVER_CADIR serverCA-ec
-x "Cu,Cu,Cu" ${D_SERVER_CA} "2" ${CA_CURVE}
451 ALL_CU_SUBJECT
="CN=NSS Chain1 Server Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
452 cert_ec_CA
$SERVER_CADIR chain-1-serverCA-ec
"-c serverCA-ec" "u,u,u" ${D_SERVER_CA} "3" ${CA_CURVE}
453 ALL_CU_SUBJECT
="CN=NSS Chain2 Server Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
454 cert_ec_CA
$SERVER_CADIR chain-2-serverCA-ec
"-c chain-1-serverCA-ec" "u,u,u" ${D_SERVER_CA} "4" ${CA_CURVE}
456 ALL_CU_SUBJECT
="CN=NSS Client Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
457 cert_ec_CA
$CLIENT_CADIR clientCA-ec
-x "Tu,Cu,Cu" ${D_CLIENT_CA} "5" ${CA_CURVE}
458 ALL_CU_SUBJECT
="CN=NSS Chain1 Client Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
459 cert_ec_CA
$CLIENT_CADIR chain-1-clientCA-ec
"-c clientCA-ec" "u,u,u" ${D_CLIENT_CA} "6" ${CA_CURVE}
460 ALL_CU_SUBJECT
="CN=NSS Chain2 Client Test CA (ECC), O=BOGUS NSS, L=Santa Clara, ST=California, C=US"
461 cert_ec_CA
$CLIENT_CADIR chain-2-clientCA-ec
"-c chain-1-clientCA-ec" "u,u,u" ${D_CLIENT_CA} "7" ${CA_CURVE}
463 rm $CLIENT_CADIR/ecroot.cert
$SERVER_CADIR/ecroot.cert
464 # ecroot.cert in $CLIENT_CADIR and in $SERVER_CADIR is one of the last
470 ################################# cert_CA ################################
471 # local shell function to build the Temp. Certificate Authority (CA)
472 # used for testing purposes, creating a CA Certificate and a root cert
473 ##########################################################################
483 echo "$SCRIPTNAME: Creating a CA Certificate $NICKNAME =========================="
485 if [ ! -d "${CUR_CADIR}" ]; then
486 mkdir
-p "${CUR_CADIR}"
492 if [ -n "${MULTIACCESS_DBM}" ]; then
493 LPROFILE
="multiaccess:${DOMAIN}"
496 if [ "$SIGNER" = "-x" ] ; then # self signed -> create DB
497 CU_ACTION
="Creating CA Cert DB"
498 certu
-N -d "${LPROFILE}" -f ${R_PWFILE} 2>&1
499 if [ "$RET" -ne 0 ]; then
500 Exit
5 "Fatal - failed to create CA $NICKNAME "
503 CU_ACTION
="Loading root cert module to CA Cert DB"
504 modu
-add "RootCerts" -libfile "${ROOTCERTSFILE}" -dbdir "${LPROFILE}" 2>&1
505 if [ "$RET" -ne 0 ]; then
509 echo "$SCRIPTNAME: Certificate initialized ----------"
513 ################# Creating CA Cert ######################################
515 CU_ACTION
="Creating CA Cert $NICKNAME "
516 CU_SUBJECT
=$ALL_CU_SUBJECT
517 certu
-S -n $NICKNAME -t $TRUSTARG -v 600 $SIGNER -d ${LPROFILE} -1 -2 -5 \
518 -f ${R_PWFILE} -z ${R_NOISE_FILE} -m $CERTSERIAL 2>&1 <<CERTSCRIPT
533 if [ "$RET" -ne 0 ]; then
534 echo "return value is $RET"
535 Exit
6 "Fatal - failed to create CA cert"
538 ################# Exporting Root Cert ###################################
540 CU_ACTION
="Exporting Root Cert"
541 certu
-L -n $NICKNAME -r -d ${LPROFILE} -o root.cert
542 if [ "$RET" -ne 0 ]; then
543 Exit
7 "Fatal - failed to export root cert"
545 cp root.cert
${NICKNAME}.ca.cert
548 ################################ cert_ec_CA ##############################
549 # local shell function to build the Temp. Certificate Authority (CA)
550 # used for testing purposes, creating a CA Certificate and a root cert
551 # This is the ECC version of cert_CA.
552 ##########################################################################
563 echo "$SCRIPTNAME: Creating an EC CA Certificate $NICKNAME =========================="
565 if [ ! -d "${CUR_CADIR}" ]; then
566 mkdir
-p "${CUR_CADIR}"
572 if [ -n "${MULTIACCESS_DBM}" ]; then
573 LPROFILE
="multiaccess:${DOMAIN}"
576 ################# Creating an EC CA Cert ################################
578 CU_ACTION
="Creating EC CA Cert $NICKNAME "
579 CU_SUBJECT
=$ALL_CU_SUBJECT
580 certu
-S -n $NICKNAME -k ec
-q $CURVE -t $TRUSTARG -v 600 $SIGNER \
581 -d ${LPROFILE} -1 -2 -5 -f ${R_PWFILE} -z ${R_NOISE_FILE} \
582 -m $CERTSERIAL 2>&1 <<CERTSCRIPT
597 if [ "$RET" -ne 0 ]; then
598 echo "return value is $RET"
599 Exit
6 "Fatal - failed to create EC CA cert"
602 ################# Exporting EC Root Cert ################################
604 CU_ACTION
="Exporting EC Root Cert"
605 certu
-L -n $NICKNAME -r -d ${LPROFILE} -o ecroot.cert
606 if [ "$RET" -ne 0 ]; then
607 Exit
7 "Fatal - failed to export ec root cert"
609 cp ecroot.cert
${NICKNAME}.ca.cert
612 ############################## cert_smime_client #############################
613 # local shell function to create client Certificates for S/MIME tests
614 ##############################################################################
618 echo "$SCRIPTNAME: Creating Client CA Issued Certificates =============="
620 cert_create_cert
${ALICEDIR} "Alice" 30 ${D_ALICE}
621 cert_create_cert
${BOBDIR} "Bob" 40 ${D_BOB}
623 echo "$SCRIPTNAME: Creating Dave's Certificate -------------------------"
624 cert_create_cert
"${DAVEDIR}" Dave
50 ${D_DAVE}
626 ## XXX With this new script merging ECC and non-ECC tests, the
627 ## call to cert_create_cert ends up creating two separate certs
628 ## one for Eve and another for Eve-ec but they both end up with
629 ## the same Subject Alt Name Extension, i.e., both the cert for
630 ## Eve@bogus.com and the cert for Eve-ec@bogus.com end up
631 ## listing eve@bogus.net in the Certificate Subject Alt Name extension.
632 ## This can cause a problem later when cmsutil attempts to create
633 ## enveloped data and accidently picks up the ECC cert (NSS currently
634 ## does not support ECC for enveloped data creation). This script
635 ## avoids the problem by ensuring that these conflicting certs are
636 ## never added to the same cert database (see comment marked XXXX).
637 echo "$SCRIPTNAME: Creating multiEmail's Certificate --------------------"
638 cert_create_cert
"${EVEDIR}" "Eve" 60 ${D_EVE} "-7 eve@bogus.net,eve@bogus.cc,beve@bogus.com"
640 #echo "************* Copying CA files to ${SERVERDIR}"
644 #########################################################################
647 #CU_ACTION="Creating ${CERTNAME}'s Server Cert"
648 #CU_SUBJECT="CN=${CERTNAME}, E=${CERTNAME}@bogus.com, O=BOGUS Netscape, L=Mountain View, ST=California, C=US"
649 #certu -S -n "${CERTNAME}" -c "TestCA" -t "u,u,u" -m "$CERTSERIAL" \
650 # -d ${PROFILEDIR} -f "${R_PWFILE}" -z "${R_NOISE_FILE}" -v 60 2>&1
652 #CU_ACTION="Export Dave's Cert"
654 #certu -L -n "Dave" -r -d ${P_R_DAVE} -o Dave.cert
656 ################# Importing Certificates for S/MIME tests ###############
658 echo "$SCRIPTNAME: Importing Certificates =============================="
659 CU_ACTION
="Import Bob's cert into Alice's db"
660 certu
-E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
661 -i ${R_BOBDIR}/Bob.cert
2>&1
663 CU_ACTION
="Import Dave's cert into Alice's DB"
664 certu
-E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
665 -i ${R_DAVEDIR}/Dave.cert
2>&1
667 CU_ACTION
="Import Dave's cert into Bob's DB"
668 certu
-E -t "p,p,p" -d ${P_R_BOBDIR} -f ${R_PWFILE} \
669 -i ${R_DAVEDIR}/Dave.cert
2>&1
671 CU_ACTION
="Import Eve's cert into Alice's DB"
672 certu
-E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
673 -i ${R_EVEDIR}/Eve.cert
2>&1
675 CU_ACTION
="Import Eve's cert into Bob's DB"
676 certu
-E -t "p,p,p" -d ${P_R_BOBDIR} -f ${R_PWFILE} \
677 -i ${R_EVEDIR}/Eve.cert
2>&1
679 if [ -n "$NSS_ENABLE_ECC" ] ; then
680 echo "$SCRIPTNAME: Importing EC Certificates =============================="
681 CU_ACTION
="Import Bob's EC cert into Alice's db"
682 certu
-E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
683 -i ${R_BOBDIR}/Bob-ec.cert
2>&1
685 CU_ACTION
="Import Dave's EC cert into Alice's DB"
686 certu
-E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
687 -i ${R_DAVEDIR}/Dave-ec.cert
2>&1
689 CU_ACTION
="Import Dave's EC cert into Bob's DB"
690 certu
-E -t "p,p,p" -d ${P_R_BOBDIR} -f ${R_PWFILE} \
691 -i ${R_DAVEDIR}/Dave-ec.cert
2>&1
693 ## XXXX Do not import Eve's EC cert until we can make sure that
694 ## the email addresses listed in the Subject Alt Name Extension
695 ## inside Eve's ECC and non-ECC certs are different.
696 # CU_ACTION="Import Eve's EC cert into Alice's DB"
697 # certu -E -t "p,p,p" -d ${P_R_ALICEDIR} -f ${R_PWFILE} \
698 # -i ${R_EVEDIR}/Eve-ec.cert 2>&1
700 # CU_ACTION="Import Eve's EC cert into Bob's DB"
701 # certu -E -t "p,p,p" -d ${P_R_BOBDIR} -f ${R_PWFILE} \
702 # -i ${R_EVEDIR}/Eve-ec.cert 2>&1
705 if [ "$CERTFAILED" != 0 ] ; then
706 cert_log
"ERROR: SMIME failed $RET"
708 cert_log
"SUCCESS: SMIME passed"
712 ############################## cert_extended_ssl #######################
713 # local shell function to create client + server certs for extended SSL test
714 ########################################################################
718 ################# Creating Certs for extended SSL test ####################
721 echo "$SCRIPTNAME: Creating Certificates, issued by the last ==============="
722 echo " of a chain of CA's which are not in the same database============"
725 cert_init_cert
${EXT_SERVERDIR} "${HOSTADDR}" 1 ${D_EXT_SERVER}
727 CU_ACTION
="Initializing ${CERTNAME}'s Cert DB (ext.)"
728 certu
-N -d "${PROFILEDIR}" -f "${R_PWFILE}" 2>&1
730 CU_ACTION
="Loading root cert module to ${CERTNAME}'s Cert DB (ext.)"
731 modu
-add "RootCerts" -libfile "${ROOTCERTSFILE}" -dbdir "${PROFILEDIR}" 2>&1
733 CU_ACTION
="Generate Cert Request for $CERTNAME (ext)"
734 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
735 certu
-R -d "${PROFILEDIR}" -f "${R_PWFILE}" -z "${R_NOISE_FILE}" -o req
2>&1
737 CU_ACTION
="Sign ${CERTNAME}'s Request (ext)"
738 cp ${CERTDIR}/req
${SERVER_CADIR}
739 certu
-C -c "chain-2-serverCA" -m 200 -v 60 -d "${P_SERVER_CADIR}" \
740 -i req
-o "${CERTNAME}.cert" -f "${R_PWFILE}" 2>&1
742 CU_ACTION
="Import $CERTNAME's Cert -t u,u,u (ext)"
743 certu
-A -n "$CERTNAME" -t "u,u,u" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
744 -i "${CERTNAME}.cert" 2>&1
746 CU_ACTION
="Import Client Root CA -t T,, for $CERTNAME (ext.)"
747 certu
-A -n "clientCA" -t "T,," -f "${R_PWFILE}" -d "${PROFILEDIR}" \
748 -i "${CLIENT_CADIR}/clientCA.ca.cert" 2>&1
750 if [ -n "$NSS_ENABLE_ECC" ] ; then
752 # Repeat the above for EC certs
755 CU_ACTION
="Generate EC Cert Request for $CERTNAME (ext)"
756 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ec@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
757 certu
-R -d "${PROFILEDIR}" -k ec -q "${EC_CURVE}" -f "${R_PWFILE}" \
758 -z "${R_NOISE_FILE}" -o req
2>&1
760 CU_ACTION
="Sign ${CERTNAME}'s EC Request (ext)"
761 cp ${CERTDIR}/req
${SERVER_CADIR}
762 certu
-C -c "chain-2-serverCA-ec" -m 200 -v 60 -d "${P_SERVER_CADIR}" \
763 -i req
-o "${CERTNAME}-ec.cert" -f "${R_PWFILE}" 2>&1
765 CU_ACTION
="Import $CERTNAME's EC Cert -t u,u,u (ext)"
766 certu
-A -n "${CERTNAME}-ec" -t "u,u,u" -d "${PROFILEDIR}" \
767 -f "${R_PWFILE}" -i "${CERTNAME}-ec.cert" 2>&1
769 CU_ACTION
="Import Client EC Root CA -t T,, for $CERTNAME (ext.)"
770 certu
-A -n "clientCA-ec" -t "T,," -f "${R_PWFILE}" -d "${PROFILEDIR}" \
771 -i "${CLIENT_CADIR}/clientCA-ec.ca.cert" 2>&1
775 # Repeat again for mixed EC certs
778 CU_ACTION
="Generate mixed EC Cert Request for $CERTNAME (ext)"
779 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ecmixed@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
780 certu
-R -d "${PROFILEDIR}" -k ec -q "${EC_CURVE}" -f "${R_PWFILE}" \
781 -z "${R_NOISE_FILE}" -o req
2>&1
783 CU_ACTION
="Sign ${CERTNAME}'s mixed EC Request (ext)"
784 cp ${CERTDIR}/req
${SERVER_CADIR}
785 certu
-C -c "chain-2-serverCA" -m 201 -v 60 -d "${P_SERVER_CADIR}" \
786 -i req
-o "${CERTNAME}-ecmixed.cert" -f "${R_PWFILE}" 2>&1
788 CU_ACTION
="Import $CERTNAME's mixed EC Cert -t u,u,u (ext)"
789 certu
-A -n "${CERTNAME}-ecmixed" -t "u,u,u" -d "${PROFILEDIR}" \
790 -f "${R_PWFILE}" -i "${CERTNAME}-ecmixed.cert" 2>&1
792 # CU_ACTION="Import Client mixed EC Root CA -t T,, for $CERTNAME (ext.)"
793 # certu -A -n "clientCA-ecmixed" -t "T,," -f "${R_PWFILE}" \
794 # -d "${PROFILEDIR}" -i "${CLIENT_CADIR}/clientCA-ecmixed.ca.cert" \
798 echo "Importing all the server's own CA chain into the servers DB"
799 for CA
in `find ${SERVER_CADIR} -name "?*.ca.cert"` ;
801 N
=`basename $CA | sed -e "s/.ca.cert//"`
802 if [ $N = "serverCA" -o $N = "serverCA-ec" ] ; then
807 CU_ACTION
="Import $N CA $T for $CERTNAME (ext.) "
808 certu
-A -n $N $T -f "${R_PWFILE}" -d "${PROFILEDIR}" \
813 cert_init_cert
${EXT_CLIENTDIR} ExtendedSSLUser
1 ${D_EXT_CLIENT}
815 CU_ACTION
="Initializing ${CERTNAME}'s Cert DB (ext.)"
816 certu
-N -d "${PROFILEDIR}" -f "${R_PWFILE}" 2>&1
818 CU_ACTION
="Loading root cert module to ${CERTNAME}'s Cert DB (ext.)"
819 modu
-add "RootCerts" -libfile "${ROOTCERTSFILE}" -dbdir "${PROFILEDIR}" 2>&1
821 CU_ACTION
="Generate Cert Request for $CERTNAME (ext)"
822 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
823 certu
-R -d "${PROFILEDIR}" -f "${R_PWFILE}" -z "${R_NOISE_FILE}" \
826 CU_ACTION
="Sign ${CERTNAME}'s Request (ext)"
827 cp ${CERTDIR}/req
${CLIENT_CADIR}
828 certu
-C -c "chain-2-clientCA" -m 300 -v 60 -d "${P_CLIENT_CADIR}" \
829 -i req
-o "${CERTNAME}.cert" -f "${R_PWFILE}" 2>&1
831 CU_ACTION
="Import $CERTNAME's Cert -t u,u,u (ext)"
832 certu
-A -n "$CERTNAME" -t "u,u,u" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
833 -i "${CERTNAME}.cert" 2>&1
834 CU_ACTION
="Import Server Root CA -t C,C,C for $CERTNAME (ext.)"
835 certu
-A -n "serverCA" -t "C,C,C" -f "${R_PWFILE}" -d "${PROFILEDIR}" \
836 -i "${SERVER_CADIR}/serverCA.ca.cert" 2>&1
838 if [ -n "$NSS_ENABLE_ECC" ] ; then
840 # Repeat the above for EC certs
842 CU_ACTION
="Generate EC Cert Request for $CERTNAME (ext)"
843 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ec@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
844 certu
-R -d "${PROFILEDIR}" -k ec -q "${EC_CURVE}" -f "${R_PWFILE}" \
845 -z "${R_NOISE_FILE}" -o req
2>&1
847 CU_ACTION
="Sign ${CERTNAME}'s EC Request (ext)"
848 cp ${CERTDIR}/req
${CLIENT_CADIR}
849 certu
-C -c "chain-2-clientCA-ec" -m 300 -v 60 -d "${P_CLIENT_CADIR}" \
850 -i req
-o "${CERTNAME}-ec.cert" -f "${R_PWFILE}" 2>&1
852 CU_ACTION
="Import $CERTNAME's EC Cert -t u,u,u (ext)"
853 certu
-A -n "${CERTNAME}-ec" -t "u,u,u" -d "${PROFILEDIR}" \
854 -f "${R_PWFILE}" -i "${CERTNAME}-ec.cert" 2>&1
856 CU_ACTION
="Import Server EC Root CA -t C,C,C for $CERTNAME (ext.)"
857 certu
-A -n "serverCA-ec" -t "C,C,C" -f "${R_PWFILE}" \
858 -d "${PROFILEDIR}" -i "${SERVER_CADIR}/serverCA-ec.ca.cert" 2>&1
863 # Repeat the above for mixed EC certs
865 CU_ACTION
="Generate mixed EC Cert Request for $CERTNAME (ext)"
866 CU_SUBJECT
="CN=$CERTNAME, E=${CERTNAME}-ecmixed@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US"
867 certu
-R -d "${PROFILEDIR}" -k ec -q "${EC_CURVE}" -f "${R_PWFILE}" \
868 -z "${R_NOISE_FILE}" -o req
2>&1
870 CU_ACTION
="Sign ${CERTNAME}'s mixed EC Request (ext)"
871 cp ${CERTDIR}/req
${CLIENT_CADIR}
872 certu
-C -c "chain-2-clientCA" -m 301 -v 60 -d "${P_CLIENT_CADIR}" \
873 -i req
-o "${CERTNAME}-ecmixed.cert" -f "${R_PWFILE}" 2>&1
875 CU_ACTION
="Import $CERTNAME's mixed EC Cert -t u,u,u (ext)"
876 certu
-A -n "${CERTNAME}-ecmixed" -t "u,u,u" -d "${PROFILEDIR}" \
877 -f "${R_PWFILE}" -i "${CERTNAME}-ecmixed.cert" 2>&1
879 # CU_ACTION="Import Server EC Root CA -t C,C,C for $CERTNAME (ext.)"
880 # certu -A -n "serverCA-ec" -t "C,C,C" -f "${R_PWFILE}" \
881 # -d "${PROFILEDIR}" -i "${SERVER_CADIR}/serverCA-ec.ca.cert" 2>&1
883 # done with mixed EC certs
887 echo "Importing all the client's own CA chain into the servers DB"
888 for CA
in `find ${CLIENT_CADIR} -name "?*.ca.cert"` ;
890 N
=`basename $CA | sed -e "s/.ca.cert//"`
891 if [ $N = "clientCA" -o $N = "clientCA-ec" ] ; then
896 CU_ACTION
="Import $N CA $T for $CERTNAME (ext.)"
897 certu
-A -n $N $T -f "${R_PWFILE}" -d "${PROFILEDIR}" \
900 if [ "$CERTFAILED" != 0 ] ; then
901 cert_log
"ERROR: EXT failed $RET"
903 cert_log
"SUCCESS: EXT passed"
907 ############################## cert_ssl ################################
908 # local shell function to create client + server certs for SSL test
909 ########################################################################
912 ################# Creating Certs for SSL test ###########################
915 echo "$SCRIPTNAME: Creating Client CA Issued Certificates ==============="
916 cert_create_cert
${CLIENTDIR} "TestUser" 70 ${D_CLIENT}
918 echo "$SCRIPTNAME: Creating Server CA Issued Certificate for \\"
919 echo " ${HOSTADDR} ------------------------------------"
920 cert_create_cert
${SERVERDIR} "${HOSTADDR}" 100 ${D_SERVER}
921 CU_ACTION
="Modify trust attributes of Root CA -t TC,TC,TC"
922 certu
-M -n "TestCA" -t "TC,TC,TC" -d ${PROFILEDIR}
923 if [ -n "$NSS_ENABLE_ECC" ] ; then
924 CU_ACTION
="Modify trust attributes of EC Root CA -t TC,TC,TC"
925 certu
-M -n "TestCA-ec" -t "TC,TC,TC" -d ${PROFILEDIR}
927 # cert_init_cert ${SERVERDIR} "${HOSTADDR}" 1 ${D_SERVER}
928 # echo "************* Copying CA files to ${SERVERDIR}"
931 # CU_ACTION="Creating ${CERTNAME}'s Server Cert"
932 # CU_SUBJECT="CN=${CERTNAME}, O=BOGUS Netscape, L=Mountain View, ST=California, C=US"
933 # certu -S -n "${CERTNAME}" -c "TestCA" -t "Pu,Pu,Pu" -d ${PROFILEDIR} \
934 # -f "${R_PWFILE}" -z "${R_NOISE_FILE}" -v 60 2>&1
936 if [ "$CERTFAILED" != 0 ] ; then
937 cert_log
"ERROR: SSL failed $RET"
939 cert_log
"SUCCESS: SSL passed"
942 ############################## cert_stresscerts ################################
943 # local shell function to create client certs for SSL stresstest
944 ########################################################################
948 ############### Creating Certs for SSL stress test #######################
953 PROFILEDIR
=`cd ${CERTDIR}; pwd`
954 if [ -n "${MULTIACCESS_DBM}" ]; then
955 PROFILEDIR
="multiaccess:${D_CLIENT}"
958 echo "$SCRIPTNAME: Creating Client CA Issued Certificates ==============="
960 CONTINUE
=$GLOB_MAX_CERT
963 while [ $CONTINUE -ge $GLOB_MIN_CERT ]
965 CERTNAME
="TestUser$CONTINUE"
966 # cert_add_cert ${CLIENTDIR} "TestUser$CONTINUE" $CERTSERIAL
968 CERTSERIAL
=`expr $CERTSERIAL + 1 `
969 CONTINUE
=`expr $CONTINUE - 1 `
971 if [ "$CERTFAILED" != 0 ] ; then
972 cert_log
"ERROR: StressCert failed $RET"
974 cert_log
"SUCCESS: StressCert passed"
978 ############################## cert_fips #####################################
979 # local shell function to create certificates for FIPS tests
980 ##############################################################################
984 echo "$SCRIPTNAME: Creating FIPS 140 DSA Certificates =============="
985 cert_init_cert
"${FIPSDIR}" "FIPS PUB 140 Test Certificate" 1000 "${D_FIPS}"
987 CU_ACTION
="Initializing ${CERTNAME}'s Cert DB"
988 certu
-N -d "${PROFILEDIR}" -f "${R_FIPSPWFILE}" 2>&1
990 CU_ACTION
="Loading root cert module to ${CERTNAME}'s Cert DB (ext.)"
991 modu
-add "RootCerts" -libfile "${ROOTCERTSFILE}" -dbdir "${PROFILEDIR}" 2>&1
993 echo "$SCRIPTNAME: Enable FIPS mode on database -----------------------"
994 CU_ACTION
="Enable FIPS mode on database for ${CERTNAME}"
995 echo "modutil -dbdir ${PROFILEDIR} -fips true "
996 modutil
-dbdir ${PROFILEDIR} -fips true
2>&1 <<MODSCRIPT
1000 if [ "$RET" -ne 0 ]; then
1001 html_failed
"<TR><TD>${CU_ACTION} ($RET) "
1002 cert_log
"ERROR: ${CU_ACTION} failed $RET"
1004 html_passed
"<TR><TD>${CU_ACTION}"
1007 CU_ACTION
="Generate Certificate for ${CERTNAME}"
1008 CU_SUBJECT
="CN=${CERTNAME}, E=fips@bogus.com, O=BOGUS NSS, OU=FIPS PUB 140, L=Mountain View, ST=California, C=US"
1009 certu
-S -n ${FIPSCERTNICK} -x -t "Cu,Cu,Cu" -d "${PROFILEDIR}" -f "${R_FIPSPWFILE}" -k dsa -v 600 -m 500 -z "${R_NOISE_FILE}" 2>&1
1010 if [ "$RET" -eq 0 ]; then
1011 cert_log "SUCCESS
: FIPS passed
"
1015 ############################## cert_eccurves ###########################
1016 # local shell function to create server certs for all EC curves
1017 ########################################################################
1020 ################# Creating Certs for EC curves test ########################
1022 if [ -n "$NSS_ENABLE_ECC" ] ; then
1023 echo "$SCRIPTNAME: Creating Server CA Issued Certificate
for "
1024 echo " EC Curves Test Certificates
------------------------------------"
1026 cert_init_cert "${ECCURVES_DIR}" "EC Curves Test Certificates
" 1 ${D_ECCURVES}
1028 CU_ACTION="Initializing EC Curve
's Cert DB"
1029 certu -N -d "${PROFILEDIR}" -f "${R_PWFILE}" 2>&1
1031 CU_ACTION="Loading root cert module to EC Curve's Cert DB
"
1032 modu -add "RootCerts
" -libfile "${ROOTCERTSFILE}" -dbdir "${PROFILEDIR}" 2>&1
1034 CU_ACTION="Import EC Root CA
for $CERTNAME"
1035 certu -A -n "TestCA-ec
" -t "TC
,TC
,TC
" -f "${R_PWFILE}" \
1036 -d "${PROFILEDIR}" -i "${R_CADIR}/ecroot.cert
" 2>&1
1038 if [ -n "${NSS_ECC_MORE_THAN_SUITE_B}" ] ; then
1039 CURVE_LIST="c2pnb163v1 c2pnb163v2 c2pnb163v3 c2pnb176v1 \
1040 c2pnb208w1 c2pnb272w1 c2pnb304w1 c2pnb368w1 \
1041 c2tnb191v1 c2tnb191v2 c2tnb191v3 c2tnb239v1 \
1042 c2tnb239v2 c2tnb239v3 c2tnb359v1 c2tnb431r1 \
1043 nistb163 nistb233 nistb283 nistb409 nistb571 \
1044 nistk163 nistk233 nistk283 nistk409 nistk571 \
1045 nistp192 nistp224 nistp256 nistp384 nistp521 \
1046 prime192v1 prime192v2 prime192v3 \
1047 prime239v1 prime239v2 prime239v3 \
1048 secp112r1 secp112r2 secp128r1 secp128r2 secp160k1 \
1049 secp160r1 secp160r2 secp192k1 secp192r1 secp224k1 \
1050 secp224r1 secp256k1 secp256r1 secp384r1 secp521r1 \
1051 sect113r1 sect113r2 sect131r1 sect131r2 sect163k1 sect163r1 \
1052 sect163r2 sect193r1 sect193r2 sect233k1 sect233r1 sect239k1 \
1053 sect283k1 sect283r1 sect409k1 sect409r1 sect571k1 sect571r1
"
1055 CURVE_LIST="nistp256 nistp384 nistp521
"
1059 for CURVE in ${CURVE_LIST}
1062 CERTNAME="Curve-
${CURVE}"
1063 CERTSERIAL=`expr $CERTSERIAL + 1 `
1064 CU_ACTION="Generate EC Cert Request
for $CERTNAME"
1065 CU_SUBJECT="CN
=$CERTNAME, E
=${CERTNAME}-ec@bogus.com
, O
=BOGUS NSS
, L
=Mountain View
, ST
=California
, C
=US
"
1066 certu -R -k ec -q "${CURVE}" -d "${PROFILEDIR}" -f "${R_PWFILE}" \
1067 -z "${R_NOISE_FILE}" -o req 2>&1
1069 if [ $RET -eq 0 ] ; then
1070 CU_ACTION="Sign
${CERTNAME}'s EC Request"
1071 certu -C -c "TestCA-ec" -m "$CERTSERIAL" -v 60 -d "${P_R_CADIR}" \
1072 -i req -o "${CERTNAME}-ec.cert" -f "${R_PWFILE}" "$1" 2>&1
1075 if [ $RET -eq 0 ] ; then
1076 CU_ACTION="Import $CERTNAME's EC Cert
"
1077 certu -A -n "${CERTNAME}-ec" -t "u
,u
,u
" -d "${PROFILEDIR}" \
1078 -f "${R_PWFILE}" -i "${CERTNAME}-ec.cert
" 2>&1
1082 fi # if NSS_ENABLE_ECC=1
1084 ############################## cert_extensions ###############################
1085 # local shell function to test cert extensions generation.
1086 ##############################################################################
1093 [ $res -ne 0 ] && return 1
1095 for fl in `echo $filterList | tr \| ' '`; do
1096 fl="`echo $fl | tr _ ' '`"
1098 if [ X`echo "$fl" | cut -c 1` = 'X!' ]; then
1100 fl=`echo $fl | tr -d '!'`
1102 certutil -d ${CERT_EXTENSIONS_DIR} -L -n $CERTNAME | grep "$fl" >/dev/null 2>&1
1103 [ $? -ne $expStat ] && return 1
1113 cert_create_cert ${CERT_EXTENSIONS_DIR} $CERTNAME 90 ${D_CERT_EXTENSTIONS}
1114 TARG_FILE=${CERT_EXTENSIONS_DIR}/test.args
1116 CU_SUBJECT="CN
=$CERTNAME, E
=${CERTNAME}@bogus.com
, O
=BOGUS NSS
, L
=Mountain View
, ST
=California
, C
=US
"
1119 while read arg opt filterList; do
1120 if [ X"`echo $arg | cut -c 1`" = "X
#" ]; then
1123 if [ X
"`echo $arg | cut -c 1`" = "X!" ]; then
1124 testName
="$filterList"
1127 if [ X
"$arg" = "X=" ]; then
1128 count
=`expr $count + 1`
1129 echo "#################################################"
1130 CU_ACTION
="Testing $testName"
1131 certutil
-d ${CERT_EXTENSIONS_DIR} -D -n $CERTNAME
1132 echo certutil
-d ${CERT_EXTENSIONS_DIR} -S -n $CERTNAME \
1133 -t "u,u,u" -o /tmp
/cert
-s "${CU_SUBJECT}" -x -f ${R_PWFILE} \
1134 -z "${R_NOISE_FILE}" -$opt < $TARG_FILE
1135 certutil
-d ${CERT_EXTENSIONS_DIR} -S -n $CERTNAME -t "u,u,u" \
1136 -o /tmp
/cert
-s "${CU_SUBJECT}" -x -f ${R_PWFILE} \
1137 -z "${R_NOISE_FILE}" -$opt < $TARG_FILE
1139 echo "certutil options:"
1141 checkRes
$ret "$filterList"
1143 if [ "$RET" -ne 0 ]; then
1145 html_failed
"<TR><TD>${CU_ACTION} ($RET) "
1146 cert_log
"ERROR: ${CU_ACTION} failed $RET"
1148 html_passed
"<TR><TD>${CU_ACTION}"
1152 echo $arg >> $TARG_FILE
1154 done < ${QADIR}/cert
/certext.txt
1158 ############################## cert_crl_ssl ############################
1159 # local shell function to generate certs and crls for SSL tests
1160 ########################################################################
1164 ################# Creating Certs ###################################
1167 CERTSERIAL
=${CRL_GRP_1_BEGIN}
1171 PROFILEDIR
=`cd ${CLIENTDIR}; pwd`
1172 CRL_GRPS_END
=`expr ${CRL_GRP_1_BEGIN} + ${TOTAL_CRL_RANGE} - 1`
1173 echo "$SCRIPTNAME: Creating Client CA Issued Certificates Range $CRL_GRP_1_BEGIN - $CRL_GRPS_END ==="
1174 CU_ACTION
="Creating client test certs"
1176 while [ $CERTSERIAL -le $CRL_GRPS_END ]
1178 CERTNAME
="TestUser$CERTSERIAL"
1180 CERTSERIAL
=`expr $CERTSERIAL + 1 `
1183 #################### CRL Creation ##############################
1185 echo "$SCRIPTNAME: Creating CA CRL ====================================="
1187 CRL_GRP_END
=`expr ${CRL_GRP_1_BEGIN} + ${CRL_GRP_1_RANGE} - 1`
1188 CRL_FILE_GRP_1
=${R_SERVERDIR}/root.crl_${CRL_GRP_1_BEGIN}-${CRL_GRP_END}
1189 CRL_FILE
=${CRL_FILE_GRP_1}
1191 CRLUPDATE
=`date +%Y%m%d%H%M%SZ`
1192 CU_ACTION
="Generating CRL for range ${CRL_GRP_1_BEGIN}-${CRL_GRP_END} TestCA authority"
1193 CRL_GRP_END_
=`expr ${CRL_GRP_END} - 1`
1194 crlu
-d $CADIR -G -n "TestCA" -f ${R_PWFILE} \
1195 -o ${CRL_FILE_GRP_1}_or
<<EOF_CRLINI
1197 addcert ${CRL_GRP_1_BEGIN}-${CRL_GRP_END_} $CRL_GRP_DATE
1198 addext reasonCode 0 4
1199 addext issuerAltNames 0 "rfc822Name:caemail@ca.com|dnsName:ca.com|directoryName:CN=NSS Test CA,O=BOGUS NSS,L=Mountain View,ST=California,C=US|URI:http://ca.com|ipAddress:192.168.0.1|registerID=reg CA"
1201 # This extension should be added to the list, but currently nss has bug
1202 #addext authKeyId 0 "CN=NSS Test CA,O=BOGUS NSS,L=Mountain View,ST=California,C=US" 1
1203 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1204 chmod 600 ${CRL_FILE_GRP_1}_or
1206 if [ -n "$NSS_ENABLE_ECC" ] ; then
1207 CU_ACTION
="Generating CRL (ECC) for range ${CRL_GRP_1_BEGIN}-${CRL_GRP_END} TestCA-ec authority"
1209 # Until Bug 292285 is resolved, do not encode x400 Addresses. After
1210 # the bug is resolved, reintroduce "x400Address:x400Address" within
1211 # addext issuerAltNames ...
1212 crlu
-q -d $CADIR -G -n "TestCA-ec" -f ${R_PWFILE} \
1213 -o ${CRL_FILE_GRP_1}_or-ec
<<EOF_CRLINI
1215 addcert ${CRL_GRP_1_BEGIN}-${CRL_GRP_END_} $CRL_GRP_DATE
1216 addext reasonCode 0 4
1217 addext issuerAltNames 0 "rfc822Name:ca-ecemail@ca.com|dnsName:ca-ec.com|directoryName:CN=NSS Test CA (ECC),O=BOGUS NSS,L=Mountain View,ST=California,C=US|URI:http://ca-ec.com|ipAddress:192.168.0.1|registerID=reg CA (ECC)"
1219 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1220 chmod 600 ${CRL_FILE_GRP_1}_or-ec
1224 ############################# Modification ##################################
1226 echo "$SCRIPTNAME: Modifying CA CRL by adding one more cert ============"
1228 CRLUPDATE
=`date "+%Y%m%d%H%M%SZ"`
1229 CRL_GRP_DATE
=`date "+%Y%m%d%H%M%SZ"`
1230 CU_ACTION
="Modify CRL by adding one more cert"
1231 crlu
-d $CADIR -M -n "TestCA" -f ${R_PWFILE} -o ${CRL_FILE_GRP_1}_or1 \
1232 -i ${CRL_FILE_GRP_1}_or
<<EOF_CRLINI
1234 addcert ${CRL_GRP_END} $CRL_GRP_DATE
1236 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1237 chmod 600 ${CRL_FILE_GRP_1}_or1
1238 TEMPFILES
="$TEMPFILES ${CRL_FILE_GRP_1}_or"
1239 if [ -n "$NSS_ENABLE_ECC" ] ; then
1240 CU_ACTION
="Modify CRL (ECC) by adding one more cert"
1241 crlu
-d $CADIR -M -n "TestCA-ec" -f ${R_PWFILE} \
1242 -o ${CRL_FILE_GRP_1}_or1-ec
-i ${CRL_FILE_GRP_1}_or-ec
<<EOF_CRLINI
1244 addcert ${CRL_GRP_END} $CRL_GRP_DATE
1246 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1247 chmod 600 ${CRL_FILE_GRP_1}_or1-ec
1248 TEMPFILES
="$TEMPFILES ${CRL_FILE_GRP_1}_or-ec"
1251 ########### Removing one cert ${UNREVOKED_CERT_GRP_1} #######################
1252 echo "$SCRIPTNAME: Modifying CA CRL by removing one cert ==============="
1253 CU_ACTION
="Modify CRL by removing one cert"
1255 CRLUPDATE
=`date "+%Y%m%d%H%M%SZ"`
1256 crlu
-d $CADIR -M -n "TestCA" -f ${R_PWFILE} -o ${CRL_FILE_GRP_1} \
1257 -i ${CRL_FILE_GRP_1}_or1
<<EOF_CRLINI
1259 rmcert ${UNREVOKED_CERT_GRP_1}
1261 chmod 600 ${CRL_FILE_GRP_1}
1262 TEMPFILES
="$TEMPFILES ${CRL_FILE_GRP_1}_or1"
1263 if [ -n "$NSS_ENABLE_ECC" ] ; then
1264 CU_ACTION
="Modify CRL (ECC) by removing one cert"
1265 crlu
-d $CADIR -M -n "TestCA-ec" -f ${R_PWFILE} -o ${CRL_FILE_GRP_1}-ec \
1266 -i ${CRL_FILE_GRP_1}_or1-ec
<<EOF_CRLINI
1268 rmcert ${UNREVOKED_CERT_GRP_1}
1270 chmod 600 ${CRL_FILE_GRP_1}-ec
1271 TEMPFILES
="$TEMPFILES ${CRL_FILE_GRP_1}_or1-ec"
1274 ########### Creating second CRL which includes groups 1 and 2 ##############
1275 CRL_GRP_END
=`expr ${CRL_GRP_2_BEGIN} + ${CRL_GRP_2_RANGE} - 1`
1276 CRL_FILE_GRP_2
=${R_SERVERDIR}/root.crl_${CRL_GRP_2_BEGIN}-${CRL_GRP_END}
1278 echo "$SCRIPTNAME: Creating CA CRL for groups 1 and 2 ==============="
1280 CRLUPDATE
=`date "+%Y%m%d%H%M%SZ"`
1281 CRL_GRP_DATE
=`date "+%Y%m%d%H%M%SZ"`
1282 CU_ACTION
="Creating CRL for groups 1 and 2"
1283 crlu
-d $CADIR -M -n "TestCA" -f ${R_PWFILE} -o ${CRL_FILE_GRP_2} \
1284 -i ${CRL_FILE_GRP_1} <<EOF_CRLINI
1286 addcert ${CRL_GRP_2_BEGIN}-${CRL_GRP_END} $CRL_GRP_DATE
1287 addext invalidityDate 0 $CRLUPDATE
1288 rmcert ${UNREVOKED_CERT_GRP_2}
1290 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1291 chmod 600 ${CRL_FILE_GRP_2}
1292 if [ -n "$NSS_ENABLE_ECC" ] ; then
1293 CU_ACTION
="Creating CRL (ECC) for groups 1 and 2"
1294 crlu
-d $CADIR -M -n "TestCA-ec" -f ${R_PWFILE} -o ${CRL_FILE_GRP_2}-ec \
1295 -i ${CRL_FILE_GRP_1}-ec <<EOF_CRLINI
1297 addcert ${CRL_GRP_2_BEGIN}-${CRL_GRP_END} $CRL_GRP_DATE
1298 addext invalidityDate 0 $CRLUPDATE
1299 rmcert ${UNREVOKED_CERT_GRP_2}
1301 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1302 chmod 600 ${CRL_FILE_GRP_2}-ec
1305 ########### Creating second CRL which includes groups 1, 2 and 3 ##############
1306 CRL_GRP_END
=`expr ${CRL_GRP_3_BEGIN} + ${CRL_GRP_3_RANGE} - 1`
1307 CRL_FILE_GRP_3
=${R_SERVERDIR}/root.crl_${CRL_GRP_3_BEGIN}-${CRL_GRP_END}
1309 echo "$SCRIPTNAME: Creating CA CRL for groups 1, 2 and 3 ==============="
1311 CRLUPDATE
=`date "+%Y%m%d%H%M%SZ"`
1312 CRL_GRP_DATE
=`date "+%Y%m%d%H%M%SZ"`
1313 CU_ACTION
="Creating CRL for groups 1, 2 and 3"
1314 crlu
-d $CADIR -M -n "TestCA" -f ${R_PWFILE} -o ${CRL_FILE_GRP_3} \
1315 -i ${CRL_FILE_GRP_2} <<EOF_CRLINI
1317 addcert ${CRL_GRP_3_BEGIN}-${CRL_GRP_END} $CRL_GRP_DATE
1318 rmcert ${UNREVOKED_CERT_GRP_3}
1319 addext crlNumber 0 2
1321 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1322 chmod 600 ${CRL_FILE_GRP_3}
1323 if [ -n "$NSS_ENABLE_ECC" ] ; then
1324 CU_ACTION
="Creating CRL (ECC) for groups 1, 2 and 3"
1325 crlu
-d $CADIR -M -n "TestCA-ec" -f ${R_PWFILE} -o ${CRL_FILE_GRP_3}-ec \
1326 -i ${CRL_FILE_GRP_2}-ec <<EOF_CRLINI
1328 addcert ${CRL_GRP_3_BEGIN}-${CRL_GRP_END} $CRL_GRP_DATE
1329 rmcert ${UNREVOKED_CERT_GRP_3}
1330 addext crlNumber 0 2
1332 CRL_GEN_RES
=`expr $? + $CRL_GEN_RES`
1333 chmod 600 ${CRL_FILE_GRP_3}-ec
1336 ############ Importing Server CA Issued CRL for certs of first group #######
1338 echo "$SCRIPTNAME: Importing Server CA Issued CRL for certs ${CRL_GRP_BEGIN} trough ${CRL_GRP_END}"
1339 CU_ACTION
="Importing CRL for groups 1"
1340 crlu
-D -n TestCA
-f "${R_PWFILE}" -d "${R_SERVERDIR}"
1341 crlu
-I -i ${CRL_FILE} -n "TestCA" -f "${R_PWFILE}" -d "${R_SERVERDIR}"
1342 CRL_GEN_RES=`expr $? + $CRL_GEN_RES`
1343 if [ -n "$NSS_ENABLE_ECC" ] ; then
1344 CU_ACTION="Importing CRL
(ECC
) for groups
1"
1345 crlu -D -n TestCA-ec -f "${R_PWFILE}" -d "${R_SERVERDIR}"
1346 crlu -I -i ${CRL_FILE}-ec -n "TestCA-ec
" -f "${R_PWFILE}" \
1348 CRL_GEN_RES=`expr $? + $CRL_GEN_RES`
1351 if [ "$CERTFAILED" != 0 -o "$CRL_GEN_RES" != 0 ] ; then
1352 cert_log "ERROR
: SSL CRL prep failed
$CERTFAILED : $CRL_GEN_RES"
1354 cert_log "SUCCESS
: SSL CRL prep passed
"
1358 ############################## cert_cleanup ############################
1359 # local shell function to finish this script (no exit since it might be
1361 ########################################################################
1364 cert_log "$SCRIPTNAME: finished
$SCRIPTNAME"
1370 ################## main #################################################
1381 if [ -z "$NSS_TEST_DISABLE_CRL" ] ; then
1384 echo "$SCRIPTNAME: Skipping CRL Tests
"
1389 if [ -n "$DO_DIST_ST" -a "$DO_DIST_ST" = "TRUE
" ] ; then