Blame tests/sni-resume.sh

Packit 549fdc
#!/bin/sh
Packit 549fdc
Packit 549fdc
# Copyright (C) 2017 Thomas Klute
Packit 549fdc
#
Packit 549fdc
# Author: Thomas Klute
Packit 549fdc
#
Packit 549fdc
# This file is part of GnuTLS.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is free software; you can redistribute it and/or modify it
Packit 549fdc
# under the terms of the GNU General Public License as published by the
Packit 549fdc
# Free Software Foundation; either version 3 of the License, or (at
Packit 549fdc
# your option) any later version.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is distributed in the hope that it will be useful, but
Packit 549fdc
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
# General Public License for more details.
Packit 549fdc
#
Packit 549fdc
# You should have received a copy of the GNU Lesser General Public License
Packit 549fdc
# along with this program.  If not, see <http://www.gnu.org/licenses/>
Packit 549fdc
Packit 549fdc
srcdir="${srcdir:-.}"
Packit 549fdc
SERV="${SERV:-../src/gnutls-serv${EXEEXT}}"
Packit 549fdc
CLI="${CLI:-../src/gnutls-cli${EXEEXT}}"
Packit 549fdc
unset RETCODE
Packit 549fdc
Packit 549fdc
if ! test -x "${SERV}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if ! test -x "${CLI}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if test "${WINDIR}" != ""; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if ! test -z "${VALGRIND}"; then
Packit 549fdc
	VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
SERV="${SERV} -q"
Packit 549fdc
Packit 549fdc
. "${srcdir}/scripts/common.sh"
Packit 549fdc
Packit 549fdc
PRIORITY="NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+ANON-ECDH"
Packit 549fdc
Packit 549fdc
echo "Checking if the SNI extension is parsed in gnutls-serv during" \
Packit 549fdc
     "cache-based session resumption"
Packit 549fdc
Packit 549fdc
TMPFILE="servoutput.$$.tmp"
Packit 549fdc
Packit 549fdc
eval "${GETPORT}"
Packit 549fdc
launch_server $$ --echo --priority ${PRIORITY} --sni-hostname-fatal \
Packit 549fdc
	      --sni-hostname server.example.com --noticket 2>${TMPFILE}
Packit 549fdc
PID=$!
Packit 549fdc
wait_server ${PID}
Packit 549fdc
Packit 549fdc
${VALGRIND} "${CLI}" -p "${PORT}" 127.0.0.1 --sni-hostname server.example.com \
Packit 549fdc
	 --priority ${PRIORITY} </dev/null >/dev/null \
Packit 549fdc
	 --resume \
Packit 549fdc
    || fail ${PID} "connection and resumption should have succeeded!"
Packit 549fdc
Packit 549fdc
kill ${PID}
Packit 549fdc
wait
Packit 549fdc
Packit 549fdc
ret=0
Packit 549fdc
cat "${TMPFILE}"
Packit 549fdc
# The --sni-hostname-fatal option rejects only clients which send a
Packit 549fdc
# server name that does not match the expected one, not clients that
Packit 549fdc
# do not send an SNI extension at all. Check if the server logged a
Packit 549fdc
# missing extension.
Packit 549fdc
if grep "client did not include SNI extension" "${TMPFILE}" >/dev/null; then
Packit 549fdc
    ret=1
Packit 549fdc
    echo "SNI data missing unexpectedly!"
Packit 549fdc
fi
Packit 549fdc
rm "${TMPFILE}"
Packit 549fdc
Packit 549fdc
exit ${ret}