Get at SSL context
Gertjan Klein <gklein-qWit8jRvyhVmR6Xm/[email protected]>
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm using CherryPy to build a little appliance accessible over the web.
I use Python 3.4 and the 'builtin' SSL module, and therefore CherryPy
calls the ssl module's create_default_context(). I would like to get at
that context to change some settings, and I can't figure out how to do this.
An additional complication is that I configured CherryPy to run two
servers, one for port 80 and one for port 443. Am I doing this right?
This is the code that creates and starts the servers:
def create_server():
# Remove default server, we need two separate ones
cherrypy.server.unsubscribe()
# Create server for HTTPS
svr = cherrypy._cpserver.Server()
svr._socket_host = '0.0.0.0'
svr.socket_port = 443
svr.ssl_module = 'builtin'
svr.ssl_certificate = CERT_INFO['ssl_certificate']
svr.ssl_private_key = CERT_INFO['ssl_private_key']
svr.ssl_certificate_chain = CERT_INFO['ssl_certificate_chain']
svr.subscribe()
# Create server for HTTPS
svr = cherrypy._cpserver.Server()
svr._socket_host = "0.0.0.0"
svr.socket_port = 80
svr.subscribe()
# Mount root server and update global config
cherrypy.tree.mount(Root(), '', CONF)
cherrypy.config.update(CONF)
# Start the server
cherrypy.engine.start()
cherrypy.engine.block()
(Here, CONF is a configuration dictionary specifying static dir mount
point etc., Root is the actual server class, and CERT_INFO contains
(let's encrypt) certificate file locations.) As far as I can figure out,
the actual HTTP server is not instantiated until cherrypy.engine.start()
is called, and everything I do after that seems to be ignored (which is
odd in itself).
What can I do to access the SSL context? Is it possible at all?
Regards,
Gertjan.
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.