Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CherryPy SSL to use latest API and work on Py3 #685

Closed
wants to merge 1 commit into from

Conversation

DanielOaks
Copy link

On Py2, the ssl_certificate and ssl_private_key attributes are deprecated, and on Py3 they don't exist at all!

This PR just updates the code to use BottlePy's recommended ssl_adapter method, fixing it for Python3.

That said, I haven't actually been able to get this to work with Py2. Neither this nor the previous version work on Python2 for me, and they both result in a non-ssl server, but I suspect that's a CherryPy issue with my particular environment. Mind trying this out with a Py2 server on your own box before pulling it? I've got some test server code here

@DanielOaks DanielOaks changed the title Update CherryPy SSL to work with the latest version Update CherryPy SSL to use latest API and work on Py3 Nov 30, 2014
@avelino
Copy link
Member

avelino commented Nov 30, 2014

+1

@iLoveTux
Copy link

I've been able to get ssl with CherryPy and bottle on Python 2.7.x. I'm not sure why, but I've needed to use CherryPy's BuiltinSSLAdapter (meaning Python's builtin ssl module as opposed to PyOpenSSL [which I don't mind since the Python 2.7.9 update]). The following code creates an ssl server using bottle and CherryPy:

import bottle

app = bottle.Bottle(__name__)

@app.route("/")
def index():
    return "You are seeing this over https."

if __name__ == "__main__":
    from cherrypy.wsgiserver import CherryPyWSGIServer
    from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter

    CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(
        'cert.pem',
        'privkey.pem',
        None)

    app.run(server="cherrypy")

I'm not sure if this will help with your PR and I don't know if this works in Python 3, but I thought I would provide it anyway.

Please Note that there is a bug in CherryPy (I'm not sure about the affected versions) that reports "http" on the CLI when starting the server, but it does serve over https.

@mfm24
Copy link

mfm24 commented Jul 12, 2015

I just had this problem, and had to work out if it was a CherryPy or Bottle problem or both. It seems that the latest CherryPy (3.8.0) will happily ignore the ssl_certificate and ssl_private_key members (I don't know if using CPWSGIServer instead of CherryPyWSGIServer would help?). I fixed it in a similar way to iLoveTux.

As a more general question, is SSL actually supported by Bottle? This has been an open pull request with no comments from the bottle maintainers for over 7 months. If it's not supported why not remove the cherrypy SSL arguments?

@defnull defnull closed this in be90814 Mar 25, 2017
juergh pushed a commit to juergh/bottle that referenced this pull request May 24, 2022
If you are using this adapter, simply switch to 'cheroot'
This should fix some recent and some very old issues regarding cherrypy:

fix bottlepy#947 Leave explicit the maxima version supported the CherryPy (<= 9.0.0)
fix bottlepy#932 Add ServerAdapter (fix CherryPy ServerAdapter)
fix bottlepy#685 Update CherryPy SSL to use latest API and work on Py3
fix bottlepy#574 Allow custom bind_addr for CherryPy

(backported from commit be90814)
[juergh: Adjust context, drop modifications of test/travis-requirements.txt
 which does not exist in 0.12.]
Signed-off-by: Juerg Haefliger <juergh@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants