bottle on cherrypy server + ssl

不羁岁月 提交于 2019-11-30 03:55:47

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)

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.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!