Skip to content

Commit b6c02b1

Browse files
committed
Include host in TLS setup
This enabled SNI, and allows it to check the certificate for the correct host.
1 parent f632fa0 commit b6c02b1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

websockify/websocket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def connect(self, uri, origin=None, protocols=[]):
140140

141141
if uri.scheme in ("wss", "https"):
142142
context = ssl.create_default_context()
143-
self.socket = context.wrap_socket(self.socket)
143+
self.socket = context.wrap_socket(self.socket,
144+
server_hostname=uri.hostname)
144145
self._state = "ssl_handshake"
145146
else:
146147
self._state = "headers"

websockify/websockifyserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def socket(host, port=None, connect=False, prefer_ipv6=False,
471471
sock.connect(addrs[0][4])
472472
if use_ssl:
473473
context = ssl.create_default_context()
474-
sock = context.wrap_socket(sock)
474+
sock = context.wrap_socket(sock, server_hostname=host)
475475
else:
476476
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
477477
sock.bind(addrs[0][4])

0 commit comments

Comments
 (0)