Tests: added SNI test without hostname in request.
This commit is contained in:
@@ -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": []},
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user