-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes hitch abort a handshake when a client submits an SNI server name that is not recognized by any of the configured certificates. Fixes: #24
- Loading branch information
Showing
6 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#/bin/bash | ||
# | ||
# Test --sni-nomatch-abort | ||
# | ||
. common.sh | ||
set +o errexit | ||
|
||
#PORT2=$(($RANDOM + 1024)) | ||
|
||
$HITCH $HITCH_ARGS --backend=[hyse.org]:80 --frontend=[${LISTENADDR}]:$LISTENPORT \ | ||
certs/site1.example.com certs/site2.example.com certs/default.example.com \ | ||
--sni-nomatch-abort | ||
test "$?" = "0" || die "Hitch did not start." | ||
|
||
# No SNI - should not be affected. | ||
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE | ||
test "$?" = "0" || die "s_client failed" | ||
grep -q -c "subject=/CN=default.example.com" $DUMPFILE | ||
test "$?" = "0" || die "s_client got wrong certificate on listen port #1" | ||
|
||
# SNI request w/ valid servername | ||
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE | ||
test "$?" = "0" || die "s_client failed" | ||
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE | ||
test "$?" = "0" || die "s_client got wrong certificate in listen port #2" | ||
|
||
# SNI w/ unknown servername | ||
echo | openssl s_client -servername invalid.example.com -prexit -connect $LISTENADDR:$LISTENPORT > $DUMPFILE 2>&1 | ||
test "$?" != "0" || die "s_client did NOT fail when it should have. " | ||
grep -q -c "unrecognized name" $DUMPFILE | ||
test "$?" = "0" || die "Expected 'unrecognized name' error." | ||
|
||
CURL_EXTRA="--resolve site1.example.com:$LISTENPORT:127.0.0.1" | ||
runcurl site1.example.com $LISTENPORT |