Merge branch 'master' of https://github.com/dimaqq/websocket-client into dimaqq-master

refs #56
This commit is contained in:
liris
2014-03-18 09:20:34 +09:00
2 changed files with 4971 additions and 4 deletions

4966
cacert.pem Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,7 @@ import socket
try:
import ssl
from ssl import SSLError
from backports.ssl_match_hostname import match_hostname
HAVE_SSL = True
except ImportError:
# dummy class of SSLError for ssl none-support environment.
@@ -446,11 +447,11 @@ class WebSocket(object):
self.sock.connect((hostname, port))
if is_secure:
if HAVE_SSL:
if self.sslopt is None:
sslopt = {}
else:
sslopt = self.sslopt
sslopt = dict(cert_reqs=ssl.CERT_REQUIRED,
ca_certs=os.path.join(os.path.dirname(__file__), "cacert.pem"))
sslopt.update(self.sslopt)
self.sock = ssl.wrap_socket(self.sock, **sslopt)
match_hostname(self.sock.getpeercert(), hostname)
else:
raise WebSocketException("SSL not available.")