From f6162a8df892fdc535d394c117902cd6039f5ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= Date: Fri, 29 Dec 2017 14:06:07 +0100 Subject: [PATCH] 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. --- lib/cherrypy/wsgiserver/ssl_pyopenssl.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cherrypy/wsgiserver/ssl_pyopenssl.py b/lib/cherrypy/wsgiserver/ssl_pyopenssl.py index 62ede265..c165a9fa 100644 --- a/lib/cherrypy/wsgiserver/ssl_pyopenssl.py +++ b/lib/cherrypy/wsgiserver/ssl_pyopenssl.py @@ -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