2018-08-01 16:43:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#!/bin/bash
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# ocsp-stapling.test
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-25 10:55:41 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Test requires HAVE_OCSP and HAVE_CERTIFICATE_STATUS_REQUEST
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-28 15:37:15 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Note, this script makes connection(s) to the public Internet.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-08 10:43:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								SCRIPT_DIR="$(dirname "$0")"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [[ -z "${RETRIES_REMAINING-}" ]]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    export RETRIES_REMAINING=2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if ! ./examples/client/client -V | grep -q 3; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo 'skipping ocsp-stapling.test because TLS1.2 is not available.' 1>&2
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-21 13:11:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    exit 77
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-28 15:37:15 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if openssl s_server -help 2>&1 | fgrep -q -i ipv6 && nc -h 2>&1 | fgrep -q -i ipv6; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    IPV6_SUPPORTED=yes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    IPV6_SUPPORTED=no
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-23 00:32:52 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if ./examples/client/client '-#' | fgrep -q -e ' -DTEST_IPV6 '; then
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if [[ "$IPV6_SUPPORTED" == "no" ]]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        echo 'Skipping IPV6 test in environment lacking IPV6 support.'
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-21 13:11:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        exit 77
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    LOCALHOST='[::1]'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LOCALHOST_FOR_NC='::1'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    V4V6=6
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    V4V6_FLAG=-6
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-23 00:32:52 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LOCALHOST='127.0.0.1'
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    LOCALHOST_FOR_NC='127.0.0.1'
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if [[ "$IPV6_SUPPORTED" == "yes" ]]; then
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        V4V6_FLAG=-4
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        V4V6_FLAG=
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 17:21:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    V4V6=4
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-23 00:32:52 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-28 15:37:15 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PARENTDIR="$PWD"
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# create a unique workspace directory ending in PID for the script instance ($$)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# to make this instance orthogonal to any others running, even on same repo.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# TCP ports are also carefully formed below from the PID, to minimize conflicts.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								WORKSPACE="${PARENTDIR}/workspace.pid$$"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								mkdir "${WORKSPACE}" || exit $?
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-08 10:43:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								cp -pR ${SCRIPT_DIR}/../certs "${WORKSPACE}"/ || exit $?
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								cd "$WORKSPACE" || exit $?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								ln -s ../examples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								CERT_DIR="./certs/ocsp"
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ready_file="$WORKSPACE"/wolf_ocsp_s1_readyF$$
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								ready_file2="$WORKSPACE"/wolf_ocsp_s1_readyF2$$
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n' "ready file:  \"$ready_file\""
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test_cnf="ocsp_s1.cnf"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wait_for_readyFile(){
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    counter=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    while [ ! -s "$1" -a "$counter" -lt 20 ]; do
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-09 12:28:22 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if [[ -n "${2-}" ]]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if ! kill -0 $2 2>&-; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                echo "pid $2 for port ${3-} exited before creating ready file.  bailing..."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fi
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        echo -e "waiting for ready file..."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        sleep 0.1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        counter=$((counter+ 1))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    done
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if test -e "$1"; then
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        echo -e "found ready file, starting client..."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        echo -e "NO ready file at \"$1\" -- ending test..."
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								remove_single_rF(){
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if test -e "$1"; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "removing ready file: \"$1\""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        rm "$1"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#create a configure file for cert generation with the port 0 solution
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								create_new_cnf() {
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-23 00:32:52 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "Random Port Selected: $1"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "#" > $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# openssl configuration file for OCSP certificates" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "#" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# Extensions to add to a certificate request (intermediate1-ca)" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "[ v3_req1 ]" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "basicConstraints       = CA:false" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "subjectKeyIdentifier   = hash" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityKeyIdentifier = keyid:always,issuer:always" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "keyUsage               = nonRepudiation, digitalSignature, keyEncipherment" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityInfoAccess    = OCSP;URI:http://127.0.0.1:$1" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# Extensions to add to a certificate request (intermediate2-ca)" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "[ v3_req2 ]" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "basicConstraints       = CA:false" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "subjectKeyIdentifier   = hash" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityKeyIdentifier = keyid:always,issuer:always" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "keyUsage               = nonRepudiation, digitalSignature, keyEncipherment" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityInfoAccess    = OCSP;URI:http://127.0.0.1:22222" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# Extensions to add to a certificate request (intermediate3-ca)" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "[ v3_req3 ]" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "basicConstraints       = CA:false" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "subjectKeyIdentifier   = hash" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityKeyIdentifier = keyid:always,issuer:always" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "keyUsage               = nonRepudiation, digitalSignature, keyEncipherment" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityInfoAccess    = OCSP;URI:http://127.0.0.1:22223" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# Extensions for a typical CA" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "[ v3_ca ]" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "basicConstraints       = CA:true" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "subjectKeyIdentifier   = hash" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityKeyIdentifier = keyid:always,issuer:always" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "keyUsage               = keyCertSign, cRLSign" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityInfoAccess    = OCSP;URI:http://127.0.0.1:22220" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "# OCSP extensions." >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "[ v3_ocsp ]" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "basicConstraints       = CA:false" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "subjectKeyIdentifier   = hash" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "authorityKeyIdentifier = keyid:always,issuer:always" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "extendedKeyUsage       = OCSPSigning" >> $test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    mv $test_cnf $CERT_DIR/$test_cnf
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    cd $CERT_DIR
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    CURR_LOC="$PWD"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "echo now in $CURR_LOC"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./renewcerts-for-test.sh $test_cnf
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    cd "$WORKSPACE"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								remove_ready_file() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if test -e "$ready_file"; then
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "removing ready file"
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        rm "$ready_file"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if test -e "$ready_file2"; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "removing ready file: \"$ready_file2\""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        rm "$ready_file2"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-02 11:32:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								cleanup()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    exit_status=$?
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-02 11:32:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for i in $(jobs -pr)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    do
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        kill -s HUP "$i"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    done
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    remove_ready_file
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    rm $CERT_DIR/$test_cnf
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    cd "$PARENTDIR" || return 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    rm -r "$WORKSPACE" || return 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [[ ("$exit_status" == 1) && ($RETRIES_REMAINING -gt 0) ]]; then
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-09 12:28:22 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        echo "retrying..."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        RETRIES_REMAINING=$((RETRIES_REMAINING - 1))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        exec $0 "$@"
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-02 11:32:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								trap cleanup EXIT INT TERM HUP
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ ! -x ./examples/client/client ] && echo -e "\n\nClient doesn't exist" && exit 1
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-24 22:40:48 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/client/client '-?' 2>&1 | grep -- 'Client not compiled in!'
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [ $? -eq 0 ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    exit 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-08 15:16:32 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# check if supported key size is large enough to handle 4096 bit RSA
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								size="$(./examples/client/client '-?' | grep "Max RSA key")"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								size="${size//[^0-9]/}"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-08 15:16:32 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [ ! -z "$size" ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf 'check on max key size of %d ...' $size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [ $size -lt 4096 ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "4096 bit RSA keys not supported"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        exit 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf 'OK\n'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# choose consecutive ports based on the PID, skipping any that are
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# already bound, to avoid the birthday problem in case other
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# instances are sharing this host.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								get_first_free_port() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    local ret="$1"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    while :; do
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-09 12:28:22 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if [[ "$ret" -ge 65536 ]]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ret=1024
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if ! nc -z $V4V6_FLAG $LOCALHOST_FOR_NC "$ret"; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            break
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ret=$((ret+1))
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    done
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo "$ret"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								base_port=$((((($$ + $RETRIES_REMAINING) * 5) % (65536 - 2048)) + 1024))
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								port1=$(get_first_free_port $base_port)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								port2=$(get_first_free_port $((port1 + 1)))
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								port3=$(get_first_free_port $((port2 + 1)))
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-04 13:16:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# test interop fail case
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ready_file=$PWD/wolf_ocsp_readyF$$
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n' "ready file:  \"$ready_file\""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								./examples/server/server -b -p $port1 -o -R "$ready_file" &
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-04 13:16:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wolf_pid=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wait_for_readyFile "$ready_file" $wolf_pid $port1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if [ ! -f "$ready_file" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-04 13:16:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "Failed to create ready file: \"$ready_file\""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # should fail if ocspstapling is also enabled
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-27 13:52:26 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    OPENSSL_OUTPUT=$(echo "hi" | openssl s_client -status $V4V6_FLAG -connect "${LOCALHOST}:$port1" -cert ./certs/client-cert.pem -key ./certs/client-key.pem -CAfile ./certs/ocsp/root-ca-cert.pem 2>&1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-24 13:13:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    OPENSSL_RESULT=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo "$OPENSSL_OUTPUT"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fgrep -q 'self signed certificate in certificate chain' <<< "$OPENSSL_OUTPUT"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    FGREP_RESULT=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [ $OPENSSL_RESULT -eq 0 -a $FGREP_RESULT -ne 0 ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-27 14:23:55 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "Expected verification error from s_client is missing."
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        remove_single_rF "$ready_file"
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-04 13:16:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    remove_single_rF "$ready_file"
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-04 13:16:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wait $wolf_pid
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [ $? -ne 1 ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        printf '%s\n' "wolfSSL server unexpected fail value"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# create a port to use with openssl ocsp responder
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/server/server -b -p $port2 -R "$ready_file" &
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 15:30:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wolf_pid2=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wait_for_readyFile "$ready_file" $wolf_pid2 $port2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if [ ! -f "$ready_file" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "Failed to create ready file: \"$ready_file\""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n' "Random port selected: $port2"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Use client connection to shutdown the server cleanly
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -p $port2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    create_new_cnf $port2
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-25 10:55:41 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sleep 0.1
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# is our desired server there? - login.live.com doesn't answers PING
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-01 15:45:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#./scripts/ping.test $server 2
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# client test against the server
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-07 16:02:48 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								server=login.live.com
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ca=certs/external/baltimore-cybertrust-root.pem
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-08 10:43:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ca=./certs/external/ca_collection.pem
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-07 16:02:48 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [[ "$V4V6" == "4" ]]; then
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-23 00:32:52 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -C -h $server -p 443 -A $ca -g -W 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 0 ] && echo -e "\n\nClient connection failed" && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo "Skipping OCSP test on $server (IPv6 test client)"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# Test with example server
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-24 22:40:48 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/server/server '-?' 2>&1 | grep -- 'Server not compiled in!'
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if [ $? -eq 0 ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    exit 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# setup ocsp responder
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 16:43:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# OLD: ./certs/ocsp/ocspd-intermediate1-ca-issued-certs.sh &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# NEW: openssl isn't being cleaned up, invoke directly in script for cleanup
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# purposes!
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								openssl ocsp -port $port2 -nmin 1                               \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 16:43:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    -index   certs/ocsp/index-intermediate1-ca-issued-certs.txt \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    -rsigner certs/ocsp/ocsp-responder-cert.pem                 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    -rkey    certs/ocsp/ocsp-responder-key.pem                  \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    -CA      certs/ocsp/intermediate1-ca-cert.pem               \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-02 11:32:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "$@" &
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 16:43:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-25 10:55:41 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sleep 0.1
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 16:43:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# "jobs" is not portable for posix. Must use bash interpreter!
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ $(jobs -r | wc -l) -ne 1 ] && \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             printf '\n\n%s\n' "Setup ocsp responder failed, skipping" && exit 0
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "------------- TEST CASE 1 SHOULD PASS ------------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# client test against our own server - GOOD CERT
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/server/server -c certs/ocsp/server1-cert.pem -R "$ready_file2" \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         -k certs/ocsp/server1-key.pem -p $port3 &
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wolf_pid3=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wait_for_readyFile "$ready_file2" $wolf_pid3 $port3
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -p $port3
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ $RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection 1 failed" && exit 1
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "------------- TEST CASE 2 SHOULD REVOKE ----------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# client test against our own server - REVOKED CERT
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								remove_single_rF "$ready_file2"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								./examples/server/server -c certs/ocsp/server2-cert.pem -R "$ready_file2" \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         -k certs/ocsp/server2-key.pem -p $port3 &
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wolf_pid3=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								wait_for_readyFile "$ready_file2" $wolf_pid3 $port3
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-25 10:55:41 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sleep 0.1
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -p $port3
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ $RESULT -ne 1 ] && printf '\n\n%s\n' "Client connection 2 succeeded $RESULT" \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "Test successfully REVOKED!"
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if ./examples/client/client -V | grep -q 4; then
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "------------- TEST CASE 3 SHOULD PASS --------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # client test against our own server - GOOD CERT
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    remove_single_rF "$ready_file2"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./examples/server/server -c certs/ocsp/server1-cert.pem -R "$ready_file2" \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -k certs/ocsp/server1-key.pem -v 4 \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -p $port3 &
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wolf_pid3=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wait_for_readyFile "$ready_file2" $wolf_pid3 $port3
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 -F 1 \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -p $port3
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection 3 failed" && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "------------- TEST CASE 4 SHOULD PASS --------------------"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # client test against our own server, must staple - GOOD CERT
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    remove_single_rF "$ready_file2"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./examples/server/server -c certs/ocsp/server1-cert.pem -R "$ready_file2" \
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -k certs/ocsp/server1-key.pem -v 4 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                             -p $port3 &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    wolf_pid3=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wait_for_readyFile "$ready_file2" $wolf_pid3 $port3
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1m -v 4 -F 1 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                             -p $port3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection 4 failed" && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "------------- TEST CASE 5 SHOULD REVOKE ------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # client test against our own server - REVOKED CERT
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    remove_single_rF "$ready_file2"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./examples/server/server -c certs/ocsp/server2-cert.pem -R "$ready_file2" \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -k certs/ocsp/server2-key.pem -v 4 \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 16:06:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -p $port3 &
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wolf_pid3=$!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-08 18:42:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wait_for_readyFile "$ready_file2" $wolf_pid3 $port3
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 14:17:17 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -C -A certs/ocsp/root-ca-cert.pem -W 1 -v 4 -F 1 \
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-16 18:05:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             -p $port3
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 1 ] && \
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                      printf '\n\n%s\n' "Client connection 5 succeeded $RESULT" \
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-10 10:24:42 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                      && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "Test successfully REVOKED!"
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo 'skipping TLS1.3 stapling tests.' 1>&2
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-02 16:59:23 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# need a unique port since may run the same time as testsuite
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								generate_port() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# Start OpenSSL server that has no OCSP responses to return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								generate_port
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-26 18:24:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								openssl s_server $V4V6_FLAG -cert ./certs/server-cert.pem -key certs/server-key.pem -www -port $port &
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								openssl_pid=$!
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								sleep 0.1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "------------- TEST CASE 6 SHOULD PASS ----------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# client asks for OCSP staple but doesn't fail when none returned
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								./examples/client/client -p $port -g -v 3 -W 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ $RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection 6 failed" && exit 1
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "------------- TEST CASE 7 SHOULD UNKNOWN -------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# client asks for OCSP staple but doesn't fail when none returned
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								./examples/client/client -p $port -g -v 3 -W 1m
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ $RESULT -ne 1 ] && printf '\n\n%s\n' "Client connection 7 succeeded $RESULT" \
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								openssl ciphers -tls1_3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								openssl_tls13=$?
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								./examples/client/client -V | grep -q 4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								wolfssl_tls13=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if [ "$openssl_tls13" = "0" -a "$wolfssl_tls13" = "0" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "------------- TEST CASE 8 SHOULD PASS --------------------"
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # client asks for OCSP staple but doesn't fail when none returned
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -p $port -g -v 4 -W 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection 8 failed" && exit 1
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "------------- TEST CASE 9 SHOULD UNKNOWN -----------------"
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # client asks for OCSP staple but doesn't fail when none returned
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ./examples/client/client -p $port -g -v 4 -W 1m
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    RESULT=$?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ $RESULT -ne 1 ] \
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-07 15:06:04 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  && printf '\n\n%s\n' "Client connection 9 succeeded $RESULT" \
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  && exit 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    printf '%s\n\n' "Test PASSED!"
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo -n 'skipping TLS1.3 stapling interoperability test:' 1>&2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [ "$openssl_tls13" != "0" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 16:45:50 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        echo -n ' OpenSSL' 1>&2
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if [ "$wolfssl_tls13" != "0" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 16:45:50 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if [ "$openssl_tls13" != "0" ]; then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            echo -n ' and' 1>&2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        echo -n ' wolfSSL' 1>&2
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-19 11:18:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    echo -n ' missing TLS1.3 support.' 1>&2
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-15 17:27:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-25 10:55:41 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								printf '%s\n\n' "------------------- TESTS COMPLETE ---------------------------"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-28 19:38:04 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								exit 0
							 |