diff options
| author | inoguchi <> | 2016-11-06 11:56:43 +0000 |
|---|---|---|
| committer | inoguchi <> | 2016-11-06 11:56:43 +0000 |
| commit | 1f367e518011ae48c2d18d531aecda1081565360 (patch) | |
| tree | 79b0a1e9caf83d86c33fcba28adce491078f58b5 /src | |
| parent | 7037ca6041870ea100bb20bfabf2b6680b5e9679 (diff) | |
| download | openbsd-1f367e518011ae48c2d18d531aecda1081565360.tar.gz openbsd-1f367e518011ae48c2d18d531aecda1081565360.tar.bz2 openbsd-1f367e518011ae48c2d18d531aecda1081565360.zip | |
Add regress test script for openssl command.
ok beck@
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/usr.bin/openssl/Makefile | 10 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/README | 1 | ||||
| -rwxr-xr-x | src/regress/usr.bin/openssl/appstest.sh | 957 |
3 files changed, 966 insertions, 2 deletions
diff --git a/src/regress/usr.bin/openssl/Makefile b/src/regress/usr.bin/openssl/Makefile index b25182b49f..d1c609980c 100644 --- a/src/regress/usr.bin/openssl/Makefile +++ b/src/regress/usr.bin/openssl/Makefile | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.3 2015/09/16 01:39:05 lteo Exp $ | 1 | # $OpenBSD: Makefile,v 1.4 2016/11/06 11:56:43 inoguchi Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR= options | 3 | SUBDIR= options |
| 4 | 4 | ||
| 5 | CLEANFILES+= testdsa.key testdsa.pem rsakey.pem rsacert.pem dsa512.pem | 5 | CLEANFILES+= testdsa.key testdsa.pem rsakey.pem rsacert.pem dsa512.pem |
| 6 | CLEANFILES+= appstest_dir | ||
| 6 | 7 | ||
| 7 | REGRESS_TARGETS=ssl-enc ssl-dsa ssl-rsa | 8 | REGRESS_TARGETS=ssl-enc ssl-dsa ssl-rsa appstest |
| 8 | 9 | ||
| 9 | OPENSSL=/usr/bin/openssl | 10 | OPENSSL=/usr/bin/openssl |
| 10 | CLEAR1=p | 11 | CLEAR1=p |
| @@ -56,5 +57,10 @@ ssl-dsa: | |||
| 56 | sh ${.CURDIR}/testdsa.sh ${.OBJDIR} ${.CURDIR} | 57 | sh ${.CURDIR}/testdsa.sh ${.OBJDIR} ${.CURDIR} |
| 57 | ssl-rsa: | 58 | ssl-rsa: |
| 58 | sh ${.CURDIR}/testrsa.sh ${.OBJDIR} ${.CURDIR} | 59 | sh ${.CURDIR}/testrsa.sh ${.OBJDIR} ${.CURDIR} |
| 60 | appstest: | ||
| 61 | sh ${.CURDIR}/appstest.sh ${.OBJDIR} ${.CURDIR} | ||
| 62 | |||
| 63 | clean: | ||
| 64 | rm -rf ${CLEANFILES} | ||
| 59 | 65 | ||
| 60 | .include <bsd.regress.mk> | 66 | .include <bsd.regress.mk> |
diff --git a/src/regress/usr.bin/openssl/README b/src/regress/usr.bin/openssl/README index 878feca400..2682d873e7 100644 --- a/src/regress/usr.bin/openssl/README +++ b/src/regress/usr.bin/openssl/README | |||
| @@ -3,4 +3,5 @@ testdsa.sh tests DSA certificate generation | |||
| 3 | test_server.sh starts a tls1 server using the above generated certificate | 3 | test_server.sh starts a tls1 server using the above generated certificate |
| 4 | test_client.sh starts a client to talk to the server. | 4 | test_client.sh starts a client to talk to the server. |
| 5 | testrsa.sh tests RSA certificate generation | 5 | testrsa.sh tests RSA certificate generation |
| 6 | appstest.sh tests openssl command | ||
| 6 | 7 | ||
diff --git a/src/regress/usr.bin/openssl/appstest.sh b/src/regress/usr.bin/openssl/appstest.sh new file mode 100755 index 0000000000..69cb511052 --- /dev/null +++ b/src/regress/usr.bin/openssl/appstest.sh | |||
| @@ -0,0 +1,957 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # appstest.sh - test script for openssl command according to man OPENSSL(1) | ||
| 4 | # | ||
| 5 | # input : none | ||
| 6 | # output : all files generated by this script go under $ssldir | ||
| 7 | # | ||
| 8 | |||
| 9 | openssl_bin=/usr/bin/openssl | ||
| 10 | |||
| 11 | uname_s=`uname -s | grep 'MINGW'` | ||
| 12 | if [ "$uname_s" = "" ] ; then | ||
| 13 | mingw=0 | ||
| 14 | else | ||
| 15 | mingw=1 | ||
| 16 | fi | ||
| 17 | |||
| 18 | function section_message { | ||
| 19 | echo "" | ||
| 20 | echo "#---------#---------#---------#---------#---------#---------#---------#--------" | ||
| 21 | echo "===" | ||
| 22 | echo "=== (Section) $1 `date +'%Y/%m/%d %H:%M:%S'`" | ||
| 23 | echo "===" | ||
| 24 | } | ||
| 25 | |||
| 26 | function start_message { | ||
| 27 | echo "" | ||
| 28 | echo "[TEST] $1" | ||
| 29 | } | ||
| 30 | |||
| 31 | function check_exit_status { | ||
| 32 | status=$1 | ||
| 33 | if [ $status -ne 0 ] ; then | ||
| 34 | echo ":-< error occurs, exit status = [ $status ]" | ||
| 35 | exit $status | ||
| 36 | else | ||
| 37 | echo ":-) success. " | ||
| 38 | fi | ||
| 39 | } | ||
| 40 | |||
| 41 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 42 | |||
| 43 | # | ||
| 44 | # create ssldir, and all files generated by this script goes under this dir. | ||
| 45 | # | ||
| 46 | ssldir="appstest_dir" | ||
| 47 | |||
| 48 | if [ -d $ssldir ] ; then | ||
| 49 | echo "directory [ $ssldir ] exists, this script deletes this directory ..." | ||
| 50 | /bin/rm -rf $ssldir | ||
| 51 | fi | ||
| 52 | |||
| 53 | mkdir -p $ssldir | ||
| 54 | |||
| 55 | export OPENSSL_CONF=$ssldir/openssl.cnf | ||
| 56 | touch $OPENSSL_CONF | ||
| 57 | |||
| 58 | user1_dir=$ssldir/user1 | ||
| 59 | mkdir -p $user1_dir | ||
| 60 | |||
| 61 | key_dir=$ssldir/key | ||
| 62 | mkdir -p $key_dir | ||
| 63 | |||
| 64 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 65 | |||
| 66 | # === COMMAND USAGE === | ||
| 67 | section_message "COMMAND USAGE" | ||
| 68 | |||
| 69 | start_message "output usages of all commands." | ||
| 70 | |||
| 71 | cmds=`$openssl_bin list-standard-commands` | ||
| 72 | $openssl_bin -help 2>> $user1_dir/usages.out | ||
| 73 | for c in $cmds ; do | ||
| 74 | $openssl_bin $c -help 2>> $user1_dir/usages.out | ||
| 75 | done | ||
| 76 | |||
| 77 | start_message "check all list-* commands." | ||
| 78 | |||
| 79 | lists="" | ||
| 80 | lists="$lists list-standard-commands" | ||
| 81 | lists="$lists list-message-digest-commands list-message-digest-algorithms" | ||
| 82 | lists="$lists list-cipher-commands list-cipher-algorithms" | ||
| 83 | lists="$lists list-public-key-algorithms" | ||
| 84 | |||
| 85 | listsfile=$user1_dir/lists.out | ||
| 86 | |||
| 87 | for l in $lists ; do | ||
| 88 | echo "" >> $listsfile | ||
| 89 | echo "$l" >> $listsfile | ||
| 90 | $openssl_bin $l >> $listsfile | ||
| 91 | done | ||
| 92 | |||
| 93 | start_message "check interactive mode" | ||
| 94 | $openssl_bin <<__EOF__ | ||
| 95 | help | ||
| 96 | quit | ||
| 97 | __EOF__ | ||
| 98 | check_exit_status $? | ||
| 99 | |||
| 100 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 101 | |||
| 102 | # --- listing operations --- | ||
| 103 | section_message "listing operations" | ||
| 104 | |||
| 105 | start_message "ciphers" | ||
| 106 | $openssl_bin ciphers -V | ||
| 107 | check_exit_status $? | ||
| 108 | |||
| 109 | start_message "errstr" | ||
| 110 | $openssl_bin errstr 2606A074 | ||
| 111 | check_exit_status $? | ||
| 112 | $openssl_bin errstr -stats 2606A074 > $user1_dir/errstr-stats.out | ||
| 113 | check_exit_status $? | ||
| 114 | |||
| 115 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 116 | |||
| 117 | # --- random number etc. operations --- | ||
| 118 | section_message "random number etc. operations" | ||
| 119 | |||
| 120 | start_message "passwd" | ||
| 121 | |||
| 122 | pass="test-pass-1234" | ||
| 123 | |||
| 124 | echo $pass | $openssl_bin passwd -stdin -1 | ||
| 125 | check_exit_status $? | ||
| 126 | |||
| 127 | echo $pass | $openssl_bin passwd -stdin -apr1 | ||
| 128 | check_exit_status $? | ||
| 129 | |||
| 130 | echo $pass | $openssl_bin passwd -stdin -crypt | ||
| 131 | check_exit_status $? | ||
| 132 | |||
| 133 | start_message "prime" | ||
| 134 | |||
| 135 | $openssl_bin prime 1 | ||
| 136 | check_exit_status $? | ||
| 137 | |||
| 138 | $openssl_bin prime 2 | ||
| 139 | check_exit_status $? | ||
| 140 | |||
| 141 | $openssl_bin prime -bits 64 -checks 3 -generate -hex -safe 5 | ||
| 142 | check_exit_status $? | ||
| 143 | |||
| 144 | start_message "rand" | ||
| 145 | |||
| 146 | $openssl_bin rand -base64 100 | ||
| 147 | check_exit_status $? | ||
| 148 | |||
| 149 | $openssl_bin rand -hex 100 | ||
| 150 | check_exit_status $? | ||
| 151 | |||
| 152 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 153 | |||
| 154 | # === MESSAGE DIGEST COMMANDS === | ||
| 155 | section_message "MESSAGE DIGEST COMMANDS" | ||
| 156 | |||
| 157 | start_message "dgst - See [MESSAGE DIGEST COMMANDS] section." | ||
| 158 | |||
| 159 | text="1234567890abcdefghijklmnopqrstuvwxyz" | ||
| 160 | dgstdat=$user1_dir/dgst.dat | ||
| 161 | echo $text > $dgstdat | ||
| 162 | hmac_key="test-hmac-key" | ||
| 163 | cmac_key="1234567890abcde1234567890abcde12" | ||
| 164 | |||
| 165 | digests=`$openssl_bin list-message-digest-commands` | ||
| 166 | |||
| 167 | for d in $digests ; do | ||
| 168 | |||
| 169 | echo -n "$d ... " | ||
| 170 | $openssl_bin dgst -$d -out $dgstdat.$d $dgstdat | ||
| 171 | check_exit_status $? | ||
| 172 | |||
| 173 | echo -n "$d HMAC ... " | ||
| 174 | $openssl_bin dgst -$d -hmac $hmac_key -out $dgstdat.$d.hmac $dgstdat | ||
| 175 | check_exit_status $? | ||
| 176 | |||
| 177 | echo -n "$d CMAC ... " | ||
| 178 | $openssl_bin dgst -$d -mac cmac -macopt cipher:aes-128-cbc -macopt hexkey:$cmac_key \ | ||
| 179 | -out $dgstdat.$d.cmac $dgstdat | ||
| 180 | check_exit_status $? | ||
| 181 | done | ||
| 182 | |||
| 183 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 184 | |||
| 185 | # === ENCODING AND CIPHER COMMANDS === | ||
| 186 | section_message "ENCODING AND CIPHER COMMANDS" | ||
| 187 | |||
| 188 | start_message "enc - See [ENCODING AND CIPHER COMMANDS] section." | ||
| 189 | |||
| 190 | text="1234567890abcdefghijklmnopqrstuvwxyz" | ||
| 191 | encfile=$user1_dir/encfile.dat | ||
| 192 | echo $text > $encfile | ||
| 193 | pass="test-pass-1234" | ||
| 194 | |||
| 195 | ciphers=`$openssl_bin list-cipher-commands` | ||
| 196 | |||
| 197 | for c in $ciphers ; do | ||
| 198 | echo -n "$c ... encoding ... " | ||
| 199 | $openssl_bin enc -$c -e -base64 -pass pass:$pass -in $encfile -out $encfile-$c.enc | ||
| 200 | check_exit_status $? | ||
| 201 | |||
| 202 | echo -n "decoding ... " | ||
| 203 | $openssl_bin enc -$c -d -base64 -pass pass:$pass -in $encfile-$c.enc -out $encfile-$c.dec | ||
| 204 | check_exit_status $? | ||
| 205 | |||
| 206 | echo -n "cmp ... " | ||
| 207 | cmp $encfile $encfile-$c.dec | ||
| 208 | check_exit_status $? | ||
| 209 | done | ||
| 210 | |||
| 211 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 212 | |||
| 213 | # === various KEY operations === | ||
| 214 | section_message "various KEY operations" | ||
| 215 | |||
| 216 | key_pass=test-key-pass | ||
| 217 | |||
| 218 | # DH | ||
| 219 | |||
| 220 | start_message "gendh - Obsoleted by dhparam." | ||
| 221 | gendh2=$key_dir/gendh2.pem | ||
| 222 | $openssl_bin gendh -2 -out $gendh2 | ||
| 223 | check_exit_status $? | ||
| 224 | |||
| 225 | start_message "dh - Obsoleted by dhparam." | ||
| 226 | $openssl_bin dh -in $gendh2 -check -text -out $gendh2.out | ||
| 227 | check_exit_status $? | ||
| 228 | |||
| 229 | start_message "dhparam - Superseded by genpkey and pkeyparam." | ||
| 230 | dhparam2=$key_dir/dhparam2.pem | ||
| 231 | $openssl_bin dhparam -2 -out $dhparam2 | ||
| 232 | check_exit_status $? | ||
| 233 | $openssl_bin dhparam -in $dhparam2 -check -text -out $dhparam2.out | ||
| 234 | check_exit_status $? | ||
| 235 | |||
| 236 | # DSA | ||
| 237 | |||
| 238 | start_message "dsaparam - Superseded by genpkey and pkeyparam." | ||
| 239 | dsaparam512=$key_dir/dsaparam512.pem | ||
| 240 | $openssl_bin dsaparam -genkey -out $dsaparam512 512 | ||
| 241 | check_exit_status $? | ||
| 242 | |||
| 243 | start_message "dsa" | ||
| 244 | $openssl_bin dsa -in $dsaparam512 -text -out $dsaparam512.out | ||
| 245 | check_exit_status $? | ||
| 246 | |||
| 247 | start_message "gendsa - Superseded by genpkey and pkey." | ||
| 248 | gendsa_des3=$key_dir/gendsa_des3.pem | ||
| 249 | $openssl_bin gendsa -des3 -out $gendsa_des3 -passout pass:$key_pass $dsaparam512 | ||
| 250 | check_exit_status $? | ||
| 251 | |||
| 252 | # RSA | ||
| 253 | |||
| 254 | start_message "genrsa - Superseded by genpkey." | ||
| 255 | genrsa_aes256=$key_dir/genrsa_aes256.pem | ||
| 256 | $openssl_bin genrsa -f4 -aes256 -out $genrsa_aes256 -passout pass:$key_pass 2048 | ||
| 257 | check_exit_status $? | ||
| 258 | |||
| 259 | start_message "rsa" | ||
| 260 | $openssl_bin rsa -in $genrsa_aes256 -passin pass:$key_pass -check -text -out $genrsa_aes256.out | ||
| 261 | check_exit_status $? | ||
| 262 | |||
| 263 | start_message "rsautl - Superseded by pkeyutl." | ||
| 264 | rsautldat=$key_dir/rsautl.dat | ||
| 265 | rsautlsig=$key_dir/rsautl.sig | ||
| 266 | echo "abcdefghijklmnopqrstuvwxyz1234567890" > $rsautldat | ||
| 267 | |||
| 268 | $openssl_bin rsautl -sign -in $rsautldat -inkey $genrsa_aes256 -passin pass:$key_pass -out $rsautlsig | ||
| 269 | check_exit_status $? | ||
| 270 | |||
| 271 | $openssl_bin rsautl -verify -in $rsautlsig -inkey $genrsa_aes256 -passin pass:$key_pass | ||
| 272 | check_exit_status $? | ||
| 273 | |||
| 274 | # EC | ||
| 275 | |||
| 276 | start_message "ecparam -list-curves" | ||
| 277 | $openssl_bin ecparam -list_curves | ||
| 278 | check_exit_status $? | ||
| 279 | |||
| 280 | # get all EC curves | ||
| 281 | ec_curves=`$openssl_bin ecparam -list_curves | grep ':' | cut -d ':' -f 1` | ||
| 282 | |||
| 283 | start_message "ecparam and ec" | ||
| 284 | |||
| 285 | for curve in $ec_curves ; | ||
| 286 | do | ||
| 287 | ecparam=$key_dir/ecparam_$curve.pem | ||
| 288 | |||
| 289 | echo -n "ec - $curve ... ecparam ... " | ||
| 290 | $openssl_bin ecparam -out $ecparam -name $curve -genkey -param_enc explicit \ | ||
| 291 | -conv_form compressed -C | ||
| 292 | check_exit_status $? | ||
| 293 | |||
| 294 | echo -n "ec ... " | ||
| 295 | $openssl_bin ec -in $ecparam -text -out $ecparam.out 2> /dev/null | ||
| 296 | check_exit_status $? | ||
| 297 | done | ||
| 298 | |||
| 299 | # PKEY | ||
| 300 | |||
| 301 | start_message "genpkey" | ||
| 302 | |||
| 303 | # DH by GENPKEY | ||
| 304 | |||
| 305 | genpkey_dh_param=$key_dir/genpkey_dh_param.pem | ||
| 306 | $openssl_bin genpkey -genparam -algorithm DH -out $genpkey_dh_param \ | ||
| 307 | -pkeyopt dh_paramgen_prime_len:1024 | ||
| 308 | check_exit_status $? | ||
| 309 | |||
| 310 | genpkey_dh=$key_dir/genpkey_dh.pem | ||
| 311 | $openssl_bin genpkey -paramfile $genpkey_dh_param -out $genpkey_dh | ||
| 312 | check_exit_status $? | ||
| 313 | |||
| 314 | # DSA by GENPKEY | ||
| 315 | |||
| 316 | genpkey_dsa_param=$key_dir/genpkey_dsa_param.pem | ||
| 317 | $openssl_bin genpkey -genparam -algorithm DSA -out $genpkey_dsa_param \ | ||
| 318 | -pkeyopt dsa_paramgen_bits:1024 | ||
| 319 | check_exit_status $? | ||
| 320 | |||
| 321 | genpkey_dsa=$key_dir/genpkey_dsa.pem | ||
| 322 | $openssl_bin genpkey -paramfile $genpkey_dsa_param -out $genpkey_dsa | ||
| 323 | check_exit_status $? | ||
| 324 | |||
| 325 | # RSA by GENPKEY | ||
| 326 | |||
| 327 | genpkey_rsa=$key_dir/genpkey_rsa.pem | ||
| 328 | $openssl_bin genpkey -algorithm RSA -out $genpkey_rsa \ | ||
| 329 | -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:3 | ||
| 330 | check_exit_status $? | ||
| 331 | |||
| 332 | # EC by GENPKEY | ||
| 333 | |||
| 334 | genpkey_ec_param=$key_dir/genpkey_ec_param.pem | ||
| 335 | $openssl_bin genpkey -genparam -algorithm EC -out $genpkey_ec_param \ | ||
| 336 | -pkeyopt ec_paramgen_curve:secp384r1 | ||
| 337 | check_exit_status $? | ||
| 338 | |||
| 339 | genpkey_ec=$key_dir/genpkey_ec.pem | ||
| 340 | $openssl_bin genpkey -paramfile $genpkey_ec_param -out $genpkey_ec | ||
| 341 | check_exit_status $? | ||
| 342 | |||
| 343 | start_message "pkeyparam" | ||
| 344 | |||
| 345 | $openssl_bin pkeyparam -in $genpkey_dh_param -text -out $genpkey_dh_param.out | ||
| 346 | check_exit_status $? | ||
| 347 | |||
| 348 | $openssl_bin pkeyparam -in $genpkey_dsa_param -text -out $genpkey_dsa_param.out | ||
| 349 | check_exit_status $? | ||
| 350 | |||
| 351 | $openssl_bin pkeyparam -in $genpkey_ec_param -text -out $genpkey_ec_param.out | ||
| 352 | check_exit_status $? | ||
| 353 | |||
| 354 | start_message "pkey" | ||
| 355 | |||
| 356 | $openssl_bin pkey -in $genpkey_dh -text -out $genpkey_dh.out | ||
| 357 | check_exit_status $? | ||
| 358 | |||
| 359 | $openssl_bin pkey -in $genpkey_dsa -text -out $genpkey_dsa.out | ||
| 360 | check_exit_status $? | ||
| 361 | |||
| 362 | $openssl_bin pkey -in $genpkey_rsa -text -out $genpkey_rsa.out | ||
| 363 | check_exit_status $? | ||
| 364 | |||
| 365 | $openssl_bin pkey -in $genpkey_ec -text -out $genpkey_ec.out | ||
| 366 | check_exit_status $? | ||
| 367 | |||
| 368 | start_message "pkeyutl" | ||
| 369 | |||
| 370 | pkeyutldat=$key_dir/pkeyutl.dat | ||
| 371 | pkeyutlsig=$key_dir/pkeyutl.sig | ||
| 372 | echo "abcdefghijklmnopqrstuvwxyz1234567890" > $pkeyutldat | ||
| 373 | |||
| 374 | $openssl_bin pkeyutl -sign -in $pkeyutldat -inkey $genpkey_rsa -out $pkeyutlsig | ||
| 375 | check_exit_status $? | ||
| 376 | |||
| 377 | $openssl_bin pkeyutl -verify -in $pkeyutldat -sigfile $pkeyutlsig -inkey $genpkey_rsa | ||
| 378 | check_exit_status $? | ||
| 379 | |||
| 380 | $openssl_bin pkeyutl -verifyrecover -in $pkeyutlsig -inkey $genpkey_rsa | ||
| 381 | check_exit_status $? | ||
| 382 | |||
| 383 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 384 | |||
| 385 | section_message "setup local CA" | ||
| 386 | |||
| 387 | # | ||
| 388 | # prepare test openssl.cnf | ||
| 389 | # | ||
| 390 | |||
| 391 | ca_dir=$ssldir/testCA | ||
| 392 | tsa_dir=$ssldir/testTSA | ||
| 393 | ocsp_dir=$ssldir/testOCSP | ||
| 394 | server_dir=$ssldir/server | ||
| 395 | |||
| 396 | cat << __EOF__ > $ssldir/openssl.cnf | ||
| 397 | oid_section = new_oids | ||
| 398 | [ new_oids ] | ||
| 399 | tsa_policy1 = 1.2.3.4.1 | ||
| 400 | tsa_policy2 = 1.2.3.4.5.6 | ||
| 401 | tsa_policy3 = 1.2.3.4.5.7 | ||
| 402 | [ ca ] | ||
| 403 | default_ca = CA_default | ||
| 404 | [ CA_default ] | ||
| 405 | dir = ./$ca_dir | ||
| 406 | crl_dir = \$dir/crl | ||
| 407 | database = \$dir/index.txt | ||
| 408 | new_certs_dir = \$dir/newcerts | ||
| 409 | serial = \$dir/serial | ||
| 410 | crlnumber = \$dir/crlnumber | ||
| 411 | default_days = 1 | ||
| 412 | default_md = default | ||
| 413 | policy = policy_match | ||
| 414 | [ policy_match ] | ||
| 415 | countryName = match | ||
| 416 | stateOrProvinceName = match | ||
| 417 | organizationName = match | ||
| 418 | organizationalUnitName = optional | ||
| 419 | commonName = supplied | ||
| 420 | emailAddress = optional | ||
| 421 | [ req ] | ||
| 422 | distinguished_name = req_distinguished_name | ||
| 423 | [ req_distinguished_name ] | ||
| 424 | countryName = Country Name | ||
| 425 | countryName_default = JP | ||
| 426 | countryName_min = 2 | ||
| 427 | countryName_max = 2 | ||
| 428 | stateOrProvinceName = State or Province Name | ||
| 429 | stateOrProvinceName_default = Tokyo | ||
| 430 | organizationName = Organization Name | ||
| 431 | organizationName_default = TEST_DUMMY_COMPANY | ||
| 432 | commonName = Common Name | ||
| 433 | [ tsa ] | ||
| 434 | default_tsa = tsa_config1 | ||
| 435 | [ tsa_config1 ] | ||
| 436 | dir = ./$tsa_dir | ||
| 437 | serial = \$dir/serial | ||
| 438 | crypto_device = builtin | ||
| 439 | digests = sha1, sha256, sha384, sha512 | ||
| 440 | default_policy = tsa_policy1 | ||
| 441 | other_policies = tsa_policy2, tsa_policy3 | ||
| 442 | [ tsa_ext ] | ||
| 443 | keyUsage = critical,nonRepudiation | ||
| 444 | extendedKeyUsage = critical,timeStamping | ||
| 445 | [ ocsp_ext ] | ||
| 446 | basicConstraints = CA:FALSE | ||
| 447 | keyUsage = nonRepudiation,digitalSignature,keyEncipherment | ||
| 448 | extendedKeyUsage = OCSPSigning | ||
| 449 | __EOF__ | ||
| 450 | |||
| 451 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 452 | |||
| 453 | # | ||
| 454 | # setup test CA | ||
| 455 | # | ||
| 456 | |||
| 457 | mkdir -p $ca_dir | ||
| 458 | mkdir -p $tsa_dir | ||
| 459 | mkdir -p $ocsp_dir | ||
| 460 | mkdir -p $server_dir | ||
| 461 | |||
| 462 | mkdir -p $ca_dir/certs | ||
| 463 | mkdir -p $ca_dir/private | ||
| 464 | mkdir -p $ca_dir/crl | ||
| 465 | mkdir -p $ca_dir/newcerts | ||
| 466 | chmod 700 $ca_dir/private | ||
| 467 | echo "01" > $ca_dir/serial | ||
| 468 | touch $ca_dir/index.txt | ||
| 469 | touch $ca_dir/crlnumber | ||
| 470 | echo "01" > $ca_dir/crlnumber | ||
| 471 | |||
| 472 | # | ||
| 473 | # setup test TSA | ||
| 474 | # | ||
| 475 | mkdir -p $tsa_dir/private | ||
| 476 | chmod 700 $tsa_dir/private | ||
| 477 | echo "01" > $tsa_dir/serial | ||
| 478 | touch $tsa_dir/index.txt | ||
| 479 | |||
| 480 | # | ||
| 481 | # setup test OCSP | ||
| 482 | # | ||
| 483 | mkdir -p $ocsp_dir/private | ||
| 484 | chmod 700 $ocsp_dir/private | ||
| 485 | |||
| 486 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 487 | |||
| 488 | # --- CA initiate (generate CA key and cert) --- | ||
| 489 | |||
| 490 | start_message "req ... generate CA key and self signed cert" | ||
| 491 | |||
| 492 | ca_cert=$ca_dir/ca_cert.pem | ||
| 493 | ca_key=$ca_dir/private/ca_key.pem ca_pass=test-ca-pass | ||
| 494 | |||
| 495 | if [ $mingw = 0 ] ; then | ||
| 496 | subj='/C=JP/ST=Tokyo/O=TEST_DUMMY_COMPANY/CN=testCA.test_dummy.com/' | ||
| 497 | else | ||
| 498 | subj='//C=JP\ST=Tokyo\O=TEST_DUMMY_COMPANY\CN=testTSA.test_dummy.com\' | ||
| 499 | fi | ||
| 500 | |||
| 501 | $openssl_bin req -new -x509 -newkey rsa:2048 -out $ca_cert -keyout $ca_key \ | ||
| 502 | -days 1 -passout pass:$ca_pass -batch -subj $subj | ||
| 503 | check_exit_status $? | ||
| 504 | |||
| 505 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 506 | |||
| 507 | # --- TSA initiate (generate TSA key and cert) --- | ||
| 508 | |||
| 509 | start_message "req ... generate TSA key and cert" | ||
| 510 | |||
| 511 | # generate CSR for TSA | ||
| 512 | |||
| 513 | tsa_csr=$tsa_dir/tsa_csr.pem | ||
| 514 | tsa_key=$tsa_dir/private/tsa_key.pem | ||
| 515 | tsa_pass=test-tsa-pass | ||
| 516 | |||
| 517 | if [ $mingw = 0 ] ; then | ||
| 518 | subj='/C=JP/ST=Tokyo/O=TEST_DUMMY_COMPANY/CN=testTSA.test_dummy.com/' | ||
| 519 | else | ||
| 520 | subj='//C=JP\ST=Tokyo\O=TEST_DUMMY_COMPANY\CN=testTSA.test_dummy.com\' | ||
| 521 | fi | ||
| 522 | |||
| 523 | $openssl_bin req -new -keyout $tsa_key -out $tsa_csr -passout pass:$tsa_pass -subj $subj | ||
| 524 | check_exit_status $? | ||
| 525 | |||
| 526 | start_message "ca ... sign by CA with TSA extensions" | ||
| 527 | |||
| 528 | tsa_cert=$tsa_dir/tsa_cert.pem | ||
| 529 | |||
| 530 | $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ | ||
| 531 | -in $tsa_csr -out $tsa_cert -extensions tsa_ext | ||
| 532 | check_exit_status $? | ||
| 533 | |||
| 534 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 535 | |||
| 536 | # --- OCSP initiate (generate OCSP key and cert) --- | ||
| 537 | |||
| 538 | start_message "req ... generate OCSP key and cert" | ||
| 539 | |||
| 540 | # generate CSR for OCSP | ||
| 541 | |||
| 542 | ocsp_csr=$ocsp_dir/ocsp_csr.pem | ||
| 543 | ocsp_key=$ocsp_dir/private/ocsp_key.pem | ||
| 544 | |||
| 545 | if [ $mingw = 0 ] ; then | ||
| 546 | subj='/C=JP/ST=Tokyo/O=TEST_DUMMY_COMPANY/CN=testOCSP.test_dummy.com/' | ||
| 547 | else | ||
| 548 | subj='//C=JP\ST=Tokyo\O=TEST_DUMMY_COMPANY\CN=testOCSP.test_dummy.com\' | ||
| 549 | fi | ||
| 550 | |||
| 551 | $openssl_bin req -new -keyout $ocsp_key -nodes -out $ocsp_csr -subj $subj | ||
| 552 | check_exit_status $? | ||
| 553 | |||
| 554 | start_message "ca ... sign by CA with OCSP extensions" | ||
| 555 | |||
| 556 | ocsp_cert=$ocsp_dir/ocsp_cert.pem | ||
| 557 | |||
| 558 | $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ | ||
| 559 | -in $ocsp_csr -out $ocsp_cert -extensions ocsp_ext | ||
| 560 | check_exit_status $? | ||
| 561 | |||
| 562 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 563 | |||
| 564 | # --- server-admin operations (generate server key and csr) --- | ||
| 565 | section_message "server-admin operations (generate server key and csr)" | ||
| 566 | |||
| 567 | start_message "req ... generate server csr#1" | ||
| 568 | |||
| 569 | server_key=$server_dir/server_key.pem | ||
| 570 | server_csr=$server_dir/server_csr.pem | ||
| 571 | server_pass=test-server-pass | ||
| 572 | |||
| 573 | if [ $mingw = 0 ] ; then | ||
| 574 | subj='/C=JP/ST=Tokyo/O=TEST_DUMMY_COMPANY/CN=localhost.test_dummy.com/' | ||
| 575 | else | ||
| 576 | subj='//C=JP\ST=Tokyo\O=TEST_DUMMY_COMPANY\CN=localhost.test_dummy.com\' | ||
| 577 | fi | ||
| 578 | |||
| 579 | $openssl_bin req -new -keyout $server_key -out $server_csr -passout pass:$server_pass -subj $subj | ||
| 580 | check_exit_status $? | ||
| 581 | |||
| 582 | start_message "req ... generate server csr#2 (interactive mode)" | ||
| 583 | |||
| 584 | revoke_key=$server_dir/revoke_key.pem | ||
| 585 | revoke_csr=$server_dir/revoke_csr.pem | ||
| 586 | revoke_pass=test-revoke-pass | ||
| 587 | |||
| 588 | $openssl_bin req -new -keyout $revoke_key -out $revoke_csr -passout pass:$revoke_pass <<__EOF__ | ||
| 589 | JP | ||
| 590 | Tokyo | ||
| 591 | TEST_DUMMY_COMPANY | ||
| 592 | revoke.test_dummy.com | ||
| 593 | __EOF__ | ||
| 594 | check_exit_status $? | ||
| 595 | |||
| 596 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 597 | |||
| 598 | # --- CA operations (issue cert for server) --- | ||
| 599 | section_message "CA operations (issue cert for server)" | ||
| 600 | |||
| 601 | start_message "ca ... issue cert for server csr#1" | ||
| 602 | |||
| 603 | server_cert=$server_dir/server_cert.pem | ||
| 604 | $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ | ||
| 605 | -in $server_csr -out $server_cert | ||
| 606 | check_exit_status $? | ||
| 607 | |||
| 608 | start_message "x509 ... issue cert for server csr#2" | ||
| 609 | |||
| 610 | revoke_cert=$server_dir/revoke_cert.pem | ||
| 611 | $openssl_bin x509 -req -in $revoke_csr -CA $ca_cert -CAkey $ca_key -passin pass:$ca_pass \ | ||
| 612 | -CAcreateserial -out $revoke_cert | ||
| 613 | check_exit_status $? | ||
| 614 | |||
| 615 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 616 | |||
| 617 | # --- CA operations (revoke cert and generate crl) --- | ||
| 618 | section_message "CA operations (revoke cert and generate crl)" | ||
| 619 | |||
| 620 | start_message "ca ... revoke server cert#2" | ||
| 621 | crl_file=$ca_dir/crl.pem | ||
| 622 | $openssl_bin ca -gencrl -out $crl_file -crldays 30 -revoke $revoke_cert \ | ||
| 623 | -keyfile $ca_key -passin pass:$ca_pass -cert $ca_cert | ||
| 624 | check_exit_status $? | ||
| 625 | |||
| 626 | start_message "crl ... CA generates CRL" | ||
| 627 | $openssl_bin crl -in $crl_file -fingerprint | ||
| 628 | check_exit_status $? | ||
| 629 | |||
| 630 | crl_p7=$ca_dir/crl.p7 | ||
| 631 | start_message "crl2pkcs7 ... convert CRL to pkcs7" | ||
| 632 | $openssl_bin crl2pkcs7 -in $crl_file -certfile $ca_cert -out $crl_p7 | ||
| 633 | check_exit_status $? | ||
| 634 | |||
| 635 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 636 | |||
| 637 | # --- server-admin operations (check csr, verify cert, certhash) --- | ||
| 638 | section_message "server-admin operations (check csr, verify cert, certhash)" | ||
| 639 | |||
| 640 | start_message "asn1parse ... parse server csr#1" | ||
| 641 | $openssl_bin asn1parse -in $server_csr -i \ | ||
| 642 | -dlimit 100 -length 1000 -strparse 01 > $server_csr.asn1parse.out | ||
| 643 | check_exit_status $? | ||
| 644 | |||
| 645 | start_message "verify ... server cert#1" | ||
| 646 | $openssl_bin verify -verbose -CAfile $ca_cert $server_cert | ||
| 647 | check_exit_status $? | ||
| 648 | |||
| 649 | start_message "x509 ... get detail info about server cert#1" | ||
| 650 | $openssl_bin x509 -in $server_cert -text -C -dates -startdate -enddate \ | ||
| 651 | -fingerprint -issuer -issuer_hash -issuer_hash_old \ | ||
| 652 | -subject -subject_hash -subject_hash_old -ocsp_uri -ocspid -modulus \ | ||
| 653 | -pubkey -serial -email > $server_cert.x509.out | ||
| 654 | check_exit_status $? | ||
| 655 | |||
| 656 | if [ $mingw = 0 ] ; then | ||
| 657 | start_message "certhash" | ||
| 658 | $openssl_bin certhash -v $server_dir | ||
| 659 | check_exit_status $? | ||
| 660 | fi | ||
| 661 | |||
| 662 | # self signed | ||
| 663 | start_message "x509 ... generate self signed server cert" | ||
| 664 | server_self_cert=$server_dir/server_self_cert.pem | ||
| 665 | $openssl_bin x509 -in $server_cert -signkey $server_key -passin pass:$server_pass -out $server_self_cert | ||
| 666 | check_exit_status $? | ||
| 667 | |||
| 668 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 669 | |||
| 670 | # --- Netscape SPKAC operations --- | ||
| 671 | section_message "Netscape SPKAC operations" | ||
| 672 | |||
| 673 | # server-admin generates SPKAC | ||
| 674 | |||
| 675 | start_message "spkac" | ||
| 676 | spkacfile=$server_dir/spkac.file | ||
| 677 | |||
| 678 | $openssl_bin spkac -key $genpkey_rsa -challenge hello -out $spkacfile | ||
| 679 | check_exit_status $? | ||
| 680 | |||
| 681 | $openssl_bin spkac -in $spkacfile -verify -out $spkacfile.out | ||
| 682 | check_exit_status $? | ||
| 683 | |||
| 684 | spkacreq=$server_dir/spkac.req | ||
| 685 | cat << __EOF__ > $spkacreq | ||
| 686 | countryName = JP | ||
| 687 | stateOrProvinceName = Tokyo | ||
| 688 | organizationName = TEST_DUMMY_COMPANY | ||
| 689 | commonName = spkac.test_dummy.com | ||
| 690 | __EOF__ | ||
| 691 | cat $spkacfile >> $spkacreq | ||
| 692 | |||
| 693 | # CA signs SPKAC | ||
| 694 | start_message "ca ... CA signs SPKAC csr" | ||
| 695 | spkaccert=$server_dir/spkac.cert | ||
| 696 | $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ | ||
| 697 | -spkac $spkacreq -out $spkaccert | ||
| 698 | check_exit_status $? | ||
| 699 | |||
| 700 | start_message "x509 ... convert DER format SPKAC cert to PEM" | ||
| 701 | spkacpem=$server_dir/spkac.pem | ||
| 702 | $openssl_bin x509 -in $spkaccert -inform DER -out $spkacpem -outform PEM | ||
| 703 | check_exit_status $? | ||
| 704 | |||
| 705 | # server-admin cert verify | ||
| 706 | |||
| 707 | start_message "nseq" | ||
| 708 | $openssl_bin nseq -in $spkacpem -toseq -out $spkacpem.nseq | ||
| 709 | check_exit_status $? | ||
| 710 | |||
| 711 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 712 | |||
| 713 | # --- user1 operations (generate user1 key and csr) --- | ||
| 714 | section_message "user1 operations (generate user1 key and csr)" | ||
| 715 | |||
| 716 | # trust | ||
| 717 | start_message "x509 ... trust testCA cert" | ||
| 718 | user1_trust=$user1_dir/user1_trust_ca.pem | ||
| 719 | $openssl_bin x509 -in $ca_cert -addtrust clientAuth -setalias "trusted testCA" -purpose -out $user1_trust | ||
| 720 | check_exit_status $? | ||
| 721 | |||
| 722 | start_message "req ... generate private key and csr for user1" | ||
| 723 | |||
| 724 | user1_key=$user1_dir/user1_key.pem | ||
| 725 | user1_csr=$user1_dir/user1_csr.pem | ||
| 726 | user1_pass=test-user1-pass | ||
| 727 | |||
| 728 | if [ $mingw = 0 ] ; then | ||
| 729 | subj='/C=JP/ST=Tokyo/O=TEST_DUMMY_COMPANY/CN=user1.test_dummy.com/' | ||
| 730 | else | ||
| 731 | subj='//C=JP\ST=Tokyo\O=TEST_DUMMY_COMPANY\CN=user1.test_dummy.com\' | ||
| 732 | fi | ||
| 733 | |||
| 734 | $openssl_bin req -new -keyout $user1_key -out $user1_csr -passout pass:$user1_pass -subj $subj | ||
| 735 | check_exit_status $? | ||
| 736 | |||
| 737 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 738 | |||
| 739 | # --- CA operations (issue cert for user1) --- | ||
| 740 | section_message "CA operations (issue cert for user1)" | ||
| 741 | |||
| 742 | start_message "ca ... issue cert for user1" | ||
| 743 | |||
| 744 | user1_cert=$user1_dir/user1_cert.pem | ||
| 745 | $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ | ||
| 746 | -in $user1_csr -out $user1_cert | ||
| 747 | check_exit_status $? | ||
| 748 | |||
| 749 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 750 | |||
| 751 | # --- TSA operations --- | ||
| 752 | section_message "TSA operations" | ||
| 753 | |||
| 754 | tsa_dat=$user1_dir/tsa.dat | ||
| 755 | cat << __EOF__ > $tsa_dat | ||
| 756 | Hello Bob, | ||
| 757 | Sincerely yours | ||
| 758 | Alice | ||
| 759 | __EOF__ | ||
| 760 | |||
| 761 | # Query | ||
| 762 | start_message "ts ... create time stamp request" | ||
| 763 | |||
| 764 | tsa_tsq=$user1_dir/tsa.tsq | ||
| 765 | |||
| 766 | $openssl_bin ts -query -sha1 -data $tsa_dat -no_nonce -out $tsa_tsq | ||
| 767 | check_exit_status $? | ||
| 768 | |||
| 769 | start_message "ts ... print time stamp request" | ||
| 770 | |||
| 771 | $openssl_bin ts -query -in $tsa_tsq -text | ||
| 772 | check_exit_status $? | ||
| 773 | |||
| 774 | # Reply | ||
| 775 | start_message "ts ... create time stamp response for a request" | ||
| 776 | |||
| 777 | tsa_tsr=$user1_dir/tsa.tsr | ||
| 778 | |||
| 779 | $openssl_bin ts -reply -queryfile $tsa_tsq -inkey $tsa_key -passin pass:$tsa_pass \ | ||
| 780 | -signer $tsa_cert -chain $ca_cert -out $tsa_tsr | ||
| 781 | check_exit_status $? | ||
| 782 | |||
| 783 | # Verify | ||
| 784 | start_message "ts ... verify time stamp response" | ||
| 785 | |||
| 786 | $openssl_bin ts -verify -queryfile $tsa_tsq -in $tsa_tsr -CAfile $ca_cert -untrusted $tsa_cert | ||
| 787 | check_exit_status $? | ||
| 788 | |||
| 789 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 790 | |||
| 791 | # --- S/MIME operations --- | ||
| 792 | section_message "S/MIME operations" | ||
| 793 | |||
| 794 | smime_txt=$user1_dir/smime.txt | ||
| 795 | smime_msg=$user1_dir/smime.msg | ||
| 796 | smime_ver=$user1_dir/smime.ver | ||
| 797 | |||
| 798 | cat << __EOF__ > $smime_txt | ||
| 799 | Hello Bob, | ||
| 800 | Sincerely yours | ||
| 801 | Alice | ||
| 802 | __EOF__ | ||
| 803 | |||
| 804 | # sign | ||
| 805 | start_message "smime ... sign to message" | ||
| 806 | |||
| 807 | $openssl_bin smime -sign -in $smime_txt -text -out $smime_msg \ | ||
| 808 | -signer $user1_cert -inkey $user1_key -passin pass:$user1_pass | ||
| 809 | check_exit_status $? | ||
| 810 | |||
| 811 | # verify | ||
| 812 | start_message "smime ... verify message" | ||
| 813 | |||
| 814 | $openssl_bin smime -verify -in $smime_msg -signer $user1_cert -CAfile $ca_cert -out $smime_ver | ||
| 815 | check_exit_status $? | ||
| 816 | |||
| 817 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 818 | |||
| 819 | # --- OCSP operations --- | ||
| 820 | section_message "OCSP operations" | ||
| 821 | |||
| 822 | # request | ||
| 823 | start_message "ocsp ... create OCSP request" | ||
| 824 | |||
| 825 | ocsp_req=$user1_dir/ocsp_req.der | ||
| 826 | $openssl_bin ocsp -issuer $ca_cert -cert $server_cert -cert $revoke_cert \ | ||
| 827 | -CAfile $ca_cert -reqout $ocsp_req | ||
| 828 | check_exit_status $? | ||
| 829 | |||
| 830 | # response | ||
| 831 | start_message "ocsp ... create OCPS response for a request" | ||
| 832 | |||
| 833 | ocsp_res=$user1_dir/ocsp_res.der | ||
| 834 | $openssl_bin ocsp -index $ca_dir/index.txt -CA $ca_cert -CAfile $ca_cert \ | ||
| 835 | -rsigner $ocsp_cert -rkey $ocsp_key -reqin $ocsp_req -respout $ocsp_res -text > $ocsp_res.out 2>&1 | ||
| 836 | check_exit_status $? | ||
| 837 | |||
| 838 | # ocsp server | ||
| 839 | start_message "ocsp ... start OCSP server in background" | ||
| 840 | |||
| 841 | ocsp_port=8888 | ||
| 842 | |||
| 843 | $openssl_bin ocsp -index $ca_dir/index.txt -CA $ca_cert -CAfile $ca_cert \ | ||
| 844 | -rsigner $ocsp_cert -rkey $ocsp_key -port '*:'$ocsp_port -nrequest 1 & | ||
| 845 | check_exit_status $? | ||
| 846 | ocsp_svr_pid=$! | ||
| 847 | echo "ocsp server pid = [ $ocsp_svr_pid ]" | ||
| 848 | sleep 1 | ||
| 849 | |||
| 850 | # send query to oscp server | ||
| 851 | start_message "ocsp ... send OCSP request to server" | ||
| 852 | |||
| 853 | ocsp_qry=$user1_dir/ocsp_qry.der | ||
| 854 | $openssl_bin ocsp -issuer $ca_cert -cert $server_cert -cert $revoke_cert \ | ||
| 855 | -CAfile $ca_cert -url http://localhost:$ocsp_port -resp_text -respout $ocsp_qry > $ocsp_qry.out 2>&1 | ||
| 856 | check_exit_status $? | ||
| 857 | |||
| 858 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 859 | |||
| 860 | # --- PKCS operations --- | ||
| 861 | section_message "PKCS operations" | ||
| 862 | |||
| 863 | pkcs_pass=test-pkcs-pass | ||
| 864 | |||
| 865 | start_message "pkcs7 ... output certs in crl(pkcs7)" | ||
| 866 | $openssl_bin pkcs7 -in $crl_p7 -print_certs -text -out $crl_p7.out | ||
| 867 | check_exit_status $? | ||
| 868 | |||
| 869 | start_message "pkcs8 ... convert key to pkcs8" | ||
| 870 | $openssl_bin pkcs8 -in $user1_key -topk8 -out $user1_key.p8 \ | ||
| 871 | -passin pass:$user1_pass -passout pass:$user1_pass -v1 pbeWithSHA1AndDES-CBC -v2 des3 | ||
| 872 | check_exit_status $? | ||
| 873 | |||
| 874 | start_message "pkcs8 ... convert pkcs8 to key in DER format" | ||
| 875 | $openssl_bin pkcs8 -in $user1_key.p8 -passin pass:$user1_pass -outform DER -out $user1_key.p8.der | ||
| 876 | check_exit_status $? | ||
| 877 | |||
| 878 | start_message "pkcs12 ... create" | ||
| 879 | $openssl_bin pkcs12 -export -in $server_cert -inkey $server_key -passin pass:$server_pass \ | ||
| 880 | -certfile $ca_cert -CAfile $ca_cert -caname "server_p12" -passout pass:$pkcs_pass \ | ||
| 881 | -certpbe AES-256-CBC -keypbe AES-256-CBC -chain -out $server_cert.p12 | ||
| 882 | check_exit_status $? | ||
| 883 | |||
| 884 | start_message "pkcs12 ... verify" | ||
| 885 | $openssl_bin pkcs12 -in $server_cert.p12 -passin pass:$pkcs_pass -info -noout | ||
| 886 | check_exit_status $? | ||
| 887 | |||
| 888 | start_message "pkcs12 ... to PEM" | ||
| 889 | $openssl_bin pkcs12 -in $server_cert.p12 -passin pass:$pkcs_pass \ | ||
| 890 | -passout pass:$pkcs_pass -out $server_cert.p12.pem | ||
| 891 | check_exit_status $? | ||
| 892 | |||
| 893 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 894 | |||
| 895 | # --- client/server operations --- | ||
| 896 | section_message "client/server operations" | ||
| 897 | |||
| 898 | host="localhost" | ||
| 899 | port=4433 | ||
| 900 | sess_log=$user1_dir/s_client_sess.log | ||
| 901 | s_client_out=$user1_dir/s_client.out | ||
| 902 | |||
| 903 | start_message "s_server ... start SSL/TLS test server" | ||
| 904 | $openssl_bin s_server -accept $port -CAfile $ca_cert \ | ||
| 905 | -cert $server_cert -key $server_key -pass pass:$server_pass \ | ||
| 906 | -context "appstest.sh" -id_prefix "APPSTEST.SH" \ | ||
| 907 | -crl_check -no_ssl2 -no_ssl3 -no_tls1 \ | ||
| 908 | -nextprotoneg "http/1.1,spdy/3" -alpn "http/1.1,spdy/3" \ | ||
| 909 | -www -quiet & | ||
| 910 | check_exit_status $? | ||
| 911 | s_server_pid=$! | ||
| 912 | echo "s_server pid = [ $s_server_pid ]" | ||
| 913 | sleep 1 | ||
| 914 | |||
| 915 | start_message "s_client ... connect to SSL/TLS test server" | ||
| 916 | $openssl_bin s_client -connect $host:$port -CAfile $ca_cert \ | ||
| 917 | -showcerts -crl_check -issuer_checks -policy_check -pause -prexit \ | ||
| 918 | -nextprotoneg "spdy/3,http/1.1" -alpn "spdy/3,http/1.1" \ | ||
| 919 | -sess_out $sess_log < /dev/null > $s_client_out 2>&1 | ||
| 920 | check_exit_status $? | ||
| 921 | |||
| 922 | start_message "s_time ... connect to SSL/TLS test server" | ||
| 923 | $openssl_bin s_time -connect $host:$port -CAfile $ca_cert -time 2 | ||
| 924 | check_exit_status $? | ||
| 925 | |||
| 926 | start_message "sess_id" | ||
| 927 | $openssl_bin sess_id -in $sess_log -text -out $sess_log.out | ||
| 928 | check_exit_status $? | ||
| 929 | |||
| 930 | sleep 1 | ||
| 931 | kill -TERM $s_server_pid | ||
| 932 | wait $s_server_pid | ||
| 933 | |||
| 934 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 935 | |||
| 936 | # === PERFORMANCE === | ||
| 937 | section_message "PERFORMANCE" | ||
| 938 | |||
| 939 | start_message "speed" | ||
| 940 | $openssl_bin speed sha512 rsa2048 -multi 2 -elapsed | ||
| 941 | check_exit_status $? | ||
| 942 | |||
| 943 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 944 | |||
| 945 | # --- VERSION INFORMATION --- | ||
| 946 | section_message "VERSION INFORMATION" | ||
| 947 | |||
| 948 | start_message "version" | ||
| 949 | $openssl_bin version -a | ||
| 950 | check_exit_status $? | ||
| 951 | |||
| 952 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 953 | |||
| 954 | section_message "END" | ||
| 955 | |||
| 956 | exit 0 | ||
| 957 | |||
