fixed some error
This commit is contained in:
@@ -30,7 +30,6 @@ if six.PY3:
|
||||
else:
|
||||
from base64 import encodestring as base64encode
|
||||
|
||||
import os
|
||||
import struct
|
||||
import threading
|
||||
|
||||
@@ -254,6 +253,7 @@ class WebSocket(object):
|
||||
self.handshake_response = handshake(self.sock, *addrs, **options)
|
||||
self.connected = True
|
||||
except:
|
||||
if self.sock:
|
||||
self.sock.close()
|
||||
self.sock = None
|
||||
raise
|
||||
|
@@ -23,6 +23,7 @@ Copyright (C) 2010 Hiroki Ohtani(liris)
|
||||
import six
|
||||
import socket
|
||||
import errno
|
||||
import os
|
||||
|
||||
if six.PY3:
|
||||
from base64 import encodebytes as base64encode
|
||||
@@ -64,7 +65,7 @@ def connect(url, options, proxy):
|
||||
|
||||
if is_secure:
|
||||
if HAVE_SSL:
|
||||
sock = _ssl_socket(sock, options.sslopt)
|
||||
sock = _ssl_socket(sock, options.sslopt, hostname)
|
||||
else:
|
||||
raise WebSocketException("SSL not available.")
|
||||
|
||||
@@ -116,7 +117,7 @@ def _open_socket(addrinfo_list, sockopt, timeout):
|
||||
return sock
|
||||
|
||||
|
||||
def _ssl_socket(sock, sslopt):
|
||||
def _ssl_socket(sock, sslopt, hostname):
|
||||
sslopt = dict(cert_reqs=ssl.CERT_REQUIRED)
|
||||
certPath = os.path.join(
|
||||
os.path.dirname(__file__), "cacert.pem")
|
||||
|
@@ -20,7 +20,7 @@ Copyright (C) 2010 Hiroki Ohtani(liris)
|
||||
|
||||
"""
|
||||
|
||||
__all__ = ["HAVE_SSL", "SSLError"]
|
||||
__all__ = ["HAVE_SSL", "ssl", "SSLError"]
|
||||
|
||||
try:
|
||||
import ssl
|
||||
|
Reference in New Issue
Block a user