Fix OpenSSL SSL.ConnectionType deprecation warning

This patches the vendored cherrypy lib to work around a deprecation
warning in pyOpenSSL 17.1.0 and later by checking and using the
SSL.Connection class if available and falling back to ConnectionType.
This commit is contained in:
Felix Bünemann 2017-12-29 14:06:07 +01:00
parent a8c5f48b60
commit f6162a8df8

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