Use SSLContext.wrap_context() for SSL/TLS sockets
ssl.wrap_context() has been deprecated for some time, and has now been removed. Use the newer API instead.
This commit is contained in:
parent
f05cd203de
commit
f632fa0285
|
|
@ -139,7 +139,8 @@ class WebSocket(object):
|
|||
self.socket = socket.create_connection((uri.hostname, port))
|
||||
|
||||
if uri.scheme in ("wss", "https"):
|
||||
self.socket = ssl.wrap_socket(self.socket)
|
||||
context = ssl.create_default_context()
|
||||
self.socket = context.wrap_socket(self.socket)
|
||||
self._state = "ssl_handshake"
|
||||
else:
|
||||
self._state = "headers"
|
||||
|
|
|
|||
|
|
@ -470,7 +470,8 @@ class WebSockifyServer():
|
|||
if connect:
|
||||
sock.connect(addrs[0][4])
|
||||
if use_ssl:
|
||||
sock = ssl.wrap_socket(sock)
|
||||
context = ssl.create_default_context()
|
||||
sock = context.wrap_socket(sock)
|
||||
else:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.bind(addrs[0][4])
|
||||
|
|
|
|||
Loading…
Reference in New Issue