Merge pull request #1181 from felixbuenemann/fix-cherrypy-ssl-connection-type-deprecation

Fix OpenSSL SSL.ConnectionType deprecation warning
This commit is contained in:
JonnyWong16 2017-12-31 12:37:22 -07:00 committed by GitHub
commit 450fda18f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,6 +39,10 @@ from cherrypy import wsgiserver
try:
from OpenSSL import SSL
from OpenSSL import crypto
if hasattr(SSL, 'Connection'):
SSLConnectionType = SSL.Connection
else:
SSLConnectionType = SSL.ConnectionType
except ImportError:
SSL = None
@ -244,7 +248,7 @@ class pyOpenSSLAdapter(wsgiserver.SSLAdapter):
return ssl_environ
def makefile(self, sock, mode='r', bufsize=-1):
if SSL and isinstance(sock, SSL.ConnectionType):
if SSL and isinstance(sock, SSLConnectionType):
timeout = sock.gettimeout()
f = SSL_fileobject(sock, mode, bufsize)
f.ssl_timeout = timeout