Blame tests/server-multi-keys.sh

Packit Service 4684c1
#!/bin/sh
Packit Service 4684c1
Packit Service 4684c1
# Copyright (C) 2017 Nikos Mavrogiannopoulos
Packit Service 4684c1
#
Packit Service 4684c1
# Author: Nikos Mavrogiannopoulos
Packit Service 4684c1
#
Packit Service 4684c1
# This file is part of GnuTLS.
Packit Service 4684c1
#
Packit Service 4684c1
# GnuTLS is free software; you can redistribute it and/or modify it
Packit Service 4684c1
# under the terms of the GNU General Public License as published by the
Packit Service 4684c1
# Free Software Foundation; either version 3 of the License, or (at
Packit Service 4684c1
# your option) any later version.
Packit Service 4684c1
#
Packit Service 4684c1
# GnuTLS is distributed in the hope that it will be useful, but
Packit Service 4684c1
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 4684c1
# General Public License for more details.
Packit Service 4684c1
#
Packit Service 4684c1
# You should have received a copy of the GNU General Public License
Packit Service 4684c1
# along with GnuTLS; if not, write to the Free Software Foundation,
Packit Service 4684c1
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit Service 4684c1
Packit Service 4684c1
srcdir="${srcdir:-.}"
Packit Service 4684c1
SERV="${SERV:-../src/gnutls-serv${EXEEXT}}"
Packit Service 4684c1
CLI="${CLI:-../src/gnutls-cli${EXEEXT}}"
Packit Service 4684c1
unset RETCODE
Packit Service 4684c1
Packit Service 4684c1
if ! test -x "${SERV}"; then
Packit Service 4684c1
	exit 77
Packit Service 4684c1
fi
Packit Service 4684c1
Packit Service 4684c1
if ! test -x "${CLI}"; then
Packit Service 4684c1
	exit 77
Packit Service 4684c1
fi
Packit Service 4684c1
Packit Service 4684c1
if test "${WINDIR}" != ""; then
Packit Service 4684c1
	exit 77
Packit Service 4684c1
fi 
Packit Service 4684c1
Packit Service 4684c1
if ! test -z "${VALGRIND}"; then
Packit Service 4684c1
	VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
Packit Service 4684c1
fi
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
SERV="${SERV} -q"
Packit Service 4684c1
Packit Service 4684c1
. "${srcdir}/scripts/common.sh"
Packit Service 4684c1
Packit Service 4684c1
check_for_datefudge
Packit Service 4684c1
Packit Service 4684c1
echo "Checking whether server can utilize multiple keys"
Packit Service 4684c1
Packit Service 4684c1
KEY1=${srcdir}/../doc/credentials/x509/key-rsa.pem
Packit Service 4684c1
CERT1=${srcdir}/../doc/credentials/x509/cert-rsa.pem
Packit Service 4684c1
KEY2=${srcdir}/../doc/credentials/x509/key-ecc.pem
Packit Service 4684c1
CERT2=${srcdir}/../doc/credentials/x509/cert-ecc.pem
Packit Service 4684c1
KEY3=${srcdir}/../doc/credentials/x509/key-rsa-pss.pem
Packit Service 4684c1
CERT3=${srcdir}/../doc/credentials/x509/cert-rsa-pss.pem
Packit Service 4684c1
CAFILE=${srcdir}/../doc/credentials/x509/ca.pem
Packit Service 4684c1
TMPFILE=outcert.$$.tmp
Packit Service 4684c1
Packit Service 4684c1
eval "${GETPORT}"
Packit Service 4684c1
launch_server $$ --echo --priority "NORMAL:+ECDHE-RSA:+ECDHE-ECDSA" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit Service 4684c1
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3}
Packit Service 4684c1
PID=$!
Packit Service 4684c1
wait_server ${PID}
Packit Service 4684c1
Packit Service 4684c1
timeout 1800 datefudge "2017-08-9" \
Packit Service 4684c1
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA" 
Packit Service 4684c1
	fail ${PID} "1. handshake with RSA should have succeeded!"
Packit Service 4684c1
Packit Service 4684c1
timeout 1800 datefudge "2017-08-9" \
Packit Service 4684c1
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-ECDSA" 
Packit Service 4684c1
	fail ${PID} "2. handshake with ECC should have succeeded!"
Packit Service 4684c1
Packit Service 4684c1
timeout 1800 datefudge "2017-08-9" \
Packit Service 4684c1
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+ECDHE-RSA:-SIGN-ALL:+SIGN-RSA-SHA256" --save-cert ${TMPFILE} 
Packit Service 4684c1
	fail ${PID} "3. handshake with RSA should have succeeded!"
Packit Service 4684c1
Packit Service 4684c1
cmp ${TMPFILE} ${CERT1}
Packit Service 4684c1
if test $? != 0;then
Packit Service 4684c1
	fail ${PID} "3. the certificate used by server was not the expected"
Packit Service 4684c1
fi
Packit Service 4684c1
Packit Service 4684c1
timeout 1800 datefudge "2017-08-9" \
Packit Service 4684c1
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA:+SIGN-RSA-SHA256:+SIGN-RSA-PSS-RSAE-SHA256" --save-cert ${TMPFILE} 
Packit Service 4684c1
	fail ${PID} "4. handshake with RSA should have succeeded!"
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
# check whether the server used the RSA-PSS certificate when we asked for RSA-PSS signature
Packit Service 4684c1
timeout 1800 datefudge "2017-08-9" \
Packit Service 4684c1
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA:-SIGN-ALL:+SIGN-RSA-PSS-SHA256" --save-cert ${TMPFILE} 
Packit Service 4684c1
	fail ${PID} "4. handshake with RSA-PSS and SHA256 should have succeeded!"
Packit Service 4684c1
Packit Service 4684c1
cmp ${TMPFILE} ${CERT3}
Packit Service 4684c1
if test $? != 0;then
Packit Service 4684c1
	fail ${PID} "4. the certificate used by server was not the expected"
Packit Service 4684c1
fi
Packit Service 4684c1
Packit Service 4684c1
kill ${PID}
Packit Service 4684c1
wait
Packit Service 4684c1
Packit Service 4684c1
exit 0