Tests: added SNI test without hostname in request.

This commit is contained in:
Andrei Zeliankou
2021-07-23 15:37:03 +01:00
parent f965e358b6
commit 960ffc9967
2 changed files with 21 additions and 1 deletions

View File

@@ -168,6 +168,26 @@ basicConstraints = critical,CA:TRUE"""
self.check_cert('alt2.example.com', bundles['example.com']['subj']) self.check_cert('alt2.example.com', bundles['example.com']['subj'])
self.check_cert('blah', bundles['default']['subj']) self.check_cert('blah', bundles['default']['subj'])
def test_tls_sni_no_hostname(self):
bundles = {
"localhost.com": {"subj": "localhost.com", "alt_names": []},
"example.com": {
"subj": "example.com",
"alt_names": ["example.com"],
},
}
self.config_bundles(bundles)
self.add_tls(["localhost.com", "example.com"])
resp, sock = self.get_ssl(
headers={'Content-Length': '0', 'Connection': 'close'}, start=True,
)
assert resp['status'] == 200
assert (
sock.getpeercert()['subject'][0][0][1]
== bundles['localhost.com']['subj']
)
def test_tls_sni_upper_case(self): def test_tls_sni_upper_case(self):
bundles = { bundles = {
"localhost.com": {"subj": "LOCALHOST.COM", "alt_names": []}, "localhost.com": {"subj": "LOCALHOST.COM", "alt_names": []},

View File

@@ -45,7 +45,7 @@ class TestHTTP:
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
if 'wrapper' in kwargs: if 'wrapper' in kwargs:
server_hostname = headers.get('Host', 'localhost') server_hostname = headers.get('Host', None)
sock = kwargs['wrapper'](sock, server_hostname=server_hostname) sock = kwargs['wrapper'](sock, server_hostname=server_hostname)
connect_args = addr if sock_type == 'unix' else (addr, port) connect_args = addr if sock_type == 'unix' else (addr, port)