Use wrap_socket from ssl.SSLContext instead of ssl
Since Python 3.2 and 2.7.9, it is recommended to use the SSLContext.wrap_socket() instead of wrap_socket(). The top-level function is limited and creates an insecure client socket without server name indication or hostname matching. [1] https://docs.python.org/3/library/ssl.html#ssl.wrap_socket Change-Id: I5d61f32760d2715fdb34314f173b0efcec4a2dcf
This commit is contained in:
parent
67ea5dfbac
commit
dc9a93b6ad
|
@ -15,7 +15,7 @@
|
|||
|
||||
import base64
|
||||
import socket
|
||||
import ssl
|
||||
from ssl import SSLContext as sslc
|
||||
import struct
|
||||
import textwrap
|
||||
from urllib import parse as urlparse
|
||||
|
@ -395,7 +395,7 @@ def create_websocket(url):
|
|||
af, socktype, proto, _, sa = res
|
||||
client_socket = socket.socket(af, socktype, proto)
|
||||
if url.scheme == 'https':
|
||||
client_socket = ssl.wrap_socket(client_socket)
|
||||
client_socket = sslc().wrap_socket(client_socket)
|
||||
client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
try:
|
||||
client_socket.connect(sa)
|
||||
|
|
Loading…
Reference in New Issue