rev280, Fix Ubutuntu 15 gevent SSL incompatibility
This commit is contained in:
parent
417c6eb96f
commit
a5741704e4
2 changed files with 64 additions and 49 deletions
|
@ -4,7 +4,7 @@ import ConfigParser
|
||||||
class Config(object):
|
class Config(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.version = "0.3.1"
|
self.version = "0.3.1"
|
||||||
self.rev = 278
|
self.rev = 280
|
||||||
self.parser = self.createArguments()
|
self.parser = self.createArguments()
|
||||||
argv = sys.argv[:] # Copy command line arguments
|
argv = sys.argv[:] # Copy command line arguments
|
||||||
argv = self.parseConfig(argv) # Add arguments from config file
|
argv = self.parseConfig(argv) # Add arguments from config file
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import logging
|
import logging
|
||||||
from Config import config
|
from Config import config
|
||||||
|
|
||||||
|
|
||||||
def disableSSLCompression():
|
def disableSSLCompression():
|
||||||
import ctypes
|
import ctypes
|
||||||
import ctypes.util
|
import ctypes.util
|
||||||
|
@ -35,8 +36,10 @@ except AttributeError:
|
||||||
|
|
||||||
OldSSLSocket = __ssl__.SSLSocket
|
OldSSLSocket = __ssl__.SSLSocket
|
||||||
|
|
||||||
|
|
||||||
class NewSSLSocket(OldSSLSocket):
|
class NewSSLSocket(OldSSLSocket):
|
||||||
# Fix SSLSocket constructor
|
# Fix SSLSocket constructor
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, sock, keyfile=None, certfile=None, server_side=False,
|
self, sock, keyfile=None, certfile=None, server_side=False,
|
||||||
cert_reqs=__ssl__.CERT_REQUIRED, ssl_version=2, ca_certs=None,
|
cert_reqs=__ssl__.CERT_REQUIRED, ssl_version=2, ca_certs=None,
|
||||||
|
@ -70,10 +73,22 @@ def new_sslwrap(
|
||||||
return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)
|
return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)
|
||||||
|
|
||||||
|
|
||||||
|
# Re-add sslwrap to Python 2.7.9+
|
||||||
if not hasattr(_ssl, 'sslwrap'):
|
if not hasattr(_ssl, 'sslwrap'):
|
||||||
import inspect
|
import inspect
|
||||||
_ssl.sslwrap = new_sslwrap
|
_ssl.sslwrap = new_sslwrap
|
||||||
__ssl__.SSLSocket = NewSSLSocket
|
__ssl__.SSLSocket = NewSSLSocket
|
||||||
logging.debug("Missing SSLwrap, readded.")
|
logging.debug("Missing SSLwrap, readded.")
|
||||||
|
|
||||||
|
|
||||||
|
# Add SSLContext to gevent.ssl (Ubutunu 15 fix)
|
||||||
|
try:
|
||||||
|
import gevent
|
||||||
|
if not hasattr(gevent.ssl, "SSLContext"):
|
||||||
|
gevent.ssl.SSLContext = __ssl__.SSLContext
|
||||||
|
logging.debug("Missing SSLContext, readded.")
|
||||||
|
except Exception, err:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
logging.debug("Python SSL version: %s" % __ssl__.OPENSSL_VERSION)
|
logging.debug("Python SSL version: %s" % __ssl__.OPENSSL_VERSION)
|
Loading…
Reference in a new issue