#/bin/bash

. common.sh
set +o errexit

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" certs/wildcard.example.com certs/default.example.com
test "$?" = "0" || die "Hitch did not start."

echo | openssl s_client -servername foo.example.com -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
test "$?" = "0" || die "s_client failed"
grep -q -c "/CN=\*.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"
