Better way than this for client-side SSL?

52 views
Skip to first unread message

Simon Haines

unread,
May 16, 2012, 11:03:55 PM5/16/12
to cherryp...@googlegroups.com
I've made a ServerAdapter that saves client-side credentials (if any) to the WSGI environment, but was wondering if there's a better way to set up the default server to use it.

Here's the code:

import cherrypy.wsgiserver
from cherrypy.wsgiserver import ssl_builtin

class ClientSSLAdapter(ssl_builtin.BuiltinSSLAdapter):
    def get_environ(self, sock):
        environ = ssl_builtin.BuiltinSSLAdapter.get_environ(self, sock)
        environ['SSL_PEER_CERTIFICATE'] = sock.getpeercert()
        return environ

cherrypy.wsgiserver.wsgiserver2.ssl_adapters['client'] = 'ClientSSLAdapter'
cherrypy.config['server.ssl_module'] = 'client'

Those last two lines are the only way I could find to have the default server pick up my module. The documentation says 'Just set server.ssl_adapter to an SSLAdapter instance' but cherrypy.server has no ssl_adapter attribute. Is there a more canonical way to do this without reaching into the wsgiserver and fiddling with its adapters? Just curious.
Simon.


Reply all
Reply to author
Forward
0 new messages