Anonymous avatar Anonymous committed 9dc9e85

Update to CherryPy WSGI server to use Python's builtin 'ssl' module only if available.

Comments (0)

Files changed (1)


     from cherrypy import wsgiserver
-    from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
 except ImportError:
     print '=' * 60
     print '== You must install CherryPy (pip install cherrypy) to use the egg:PasteScript#cherrypy server'
     print '=' * 60
+    import ssl
+    from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
+except ImportError:
+    builtin = False
+    builtin = True
 def cpwsgi_server(app, global_conf=None, host='', port=None,
                   ssl_pem=None, protocol_version=None, numthreads=None,
     server = wsgiserver.CherryPyWSGIServer(bind_addr, app,
                                            server_name=server_name, **kwargs)
     if is_ssl:
-        server.ssl_module = 'builtin'
-        server.ssl_adapter = BuiltinSSLAdapter(ssl_pem, ssl_pem)
+        if builtin:
+            server.ssl_module = 'builtin'
+            server.ssl_adapter = BuiltinSSLAdapter(ssl_pem, ssl_pem)
+        else:
+            server.ssl_certificate = server.ssl_private_key = ssl_pem
     if protocol_version:
         server.protocol = protocol_version
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.