Merge branch 'master' of https://github.com/dimaqq/websocket-client into dimaqq-master
refs #56
This commit is contained in:
4966
cacert.pem
Normal file
4966
cacert.pem
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ import socket
|
|||||||
try:
|
try:
|
||||||
import ssl
|
import ssl
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
|
from backports.ssl_match_hostname import match_hostname
|
||||||
HAVE_SSL = True
|
HAVE_SSL = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# dummy class of SSLError for ssl none-support environment.
|
# dummy class of SSLError for ssl none-support environment.
|
||||||
@@ -446,11 +447,11 @@ class WebSocket(object):
|
|||||||
self.sock.connect((hostname, port))
|
self.sock.connect((hostname, port))
|
||||||
if is_secure:
|
if is_secure:
|
||||||
if HAVE_SSL:
|
if HAVE_SSL:
|
||||||
if self.sslopt is None:
|
sslopt = dict(cert_reqs=ssl.CERT_REQUIRED,
|
||||||
sslopt = {}
|
ca_certs=os.path.join(os.path.dirname(__file__), "cacert.pem"))
|
||||||
else:
|
sslopt.update(self.sslopt)
|
||||||
sslopt = self.sslopt
|
|
||||||
self.sock = ssl.wrap_socket(self.sock, **sslopt)
|
self.sock = ssl.wrap_socket(self.sock, **sslopt)
|
||||||
|
match_hostname(self.sock.getpeercert(), hostname)
|
||||||
else:
|
else:
|
||||||
raise WebSocketException("SSL not available.")
|
raise WebSocketException("SSL not available.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user