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