bottle on cherrypy server + ssl

前端 未结 2 1216
清酒与你
清酒与你 2020-12-28 20:24

I am trying to run Bottle on top of Cherrypy\'s server. I want to get SSL Support.

So far I have tried this:

from bottle import Bottle, route
from ch         


        
相关标签:
2条回答
  • 2020-12-28 21:23

    I haven't tried the following, but hopefully, it should point you in the right direction.

    WSGI is typically for communication between a web server like Apache Httpd and a Python web application, where the requests are handled by the web server and handled by the Python application. Since you want a standalone application, using a WSGI adapter doesn't sound quite right, although this is mentioned in this document (but for an old version of CherryPy).

    Newer versions of CherryPy use cherrypy.quickstart(...) for their standalone servers. This sounds more appropriate for your application. I would suggest using a configuration as described on this page, something along these lines:

    config={
        'server.socket_port': 443,
        'server.ssl_module':'pyopenssl',
        'server.ssl_certificate':'/.../host.crt',
        'server.ssl_private_key':'/.../host.key',
        'server.ssl_certificate_chain':'/.../ca_certs.crt'
    }
    
    cherrypy.config.update(config)
    cherrypy.quickstart(...)
    

    This would also be more in line with the _cserver documentation.

    (By the way, port 443 is the default for HTTPS, not 433.)

    0 讨论(0)
  • 2020-12-28 21:31

    Try using the following:

    import web
    from web.wsgiserver import CherryPyWSGIServer
    from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
    
    ssl_cert = "path/to/ssl_certificate"
    ssl_key = "path/to/ssl_private_key"
    
    CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(ssl_cert, ssl_key, None)
    
    0 讨论(0)
提交回复
热议问题