def run(self, handler): server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler) server.ssl_adapter = ssl_builtin.BuiltinSSLAdapter("certs/localhost.cert", "certs/localhost.key") try: server.start() finally: server.stop()
def run(self, server_handler): """ Overrides super to setup Cherry py with ssl and start the server. :param server_handler: originating server type :type server_handler: """ server = wsgiserver.CherryPyWSGIServer((self.host, self.port), server_handler) # Uses the following github page's recommendation for setting up the cert: # https://github.com/nickbabcock/bottle-ssl server.ssl_adapter = ssl_builtin.BuiltinSSLAdapter( 'cacert.pem', 'privkey.pem') try: server.start() finally: server.stop()
except KeyError: pass #print URLS if args.debug: OAS.debug = True OAS.endpoints = ENDPOINTS if args.port == 80: OAS.baseurl = config["baseurl"] else: if config["baseurl"].endswith("/"): config["baseurl"] = config["baseurl"][:-1] OAS.baseurl = "%s:%d" % (config["baseurl"], args.port) if not OAS.baseurl.endswith("/"): OAS.baseurl += "/" OAS.claims_userinfo_endpoint = "%s%s" % ( OAS.baseurl, UserClaimsInfoEndpoint.etype) SRV = wsgiserver.CherryPyWSGIServer(('0.0.0.0', args.port), application) SRV.ssl_adapter = ssl_builtin.BuiltinSSLAdapter("certs/server.crt", "certs/server.key") LOGGER.info("Starting server") try: SRV.start() except KeyboardInterrupt: SRV.stop()
if __name__ == '__main__': setup_server_env(conf) session_opts = { 'session.type': 'memory', 'session.cookie_expires': True, #'session.data_dir': './data', 'session.auto': True, 'session.timeout': 900 } RP = OpenIDConnect(registration_info=conf.ME, ca_bundle=conf.CA_BUNDLE) SRV = wsgiserver.CherryPyWSGIServer(('0.0.0.0', conf.PORT), SessionMiddleware(application, session_opts)) if conf.BASE.startswith("https"): from cherrypy.wsgiserver import ssl_builtin SRV.ssl_adapter = ssl_builtin.BuiltinSSLAdapter( conf.SERVER_CERT, conf.SERVER_KEY, conf.CA_BUNDLE) LOGGER.info("RP server starting listening on port:%s" % conf.PORT) print "RP server starting listening on port:%s" % conf.PORT try: SRV.start() except KeyboardInterrupt: SRV.stop()
jwks = keyjar_init(OAS, config.keys) except Exception, err: LOGGER.error("Key setup failed: %s" % err) OAS.key_setup("static", sig={"format": "jwk", "alg": "rsa"}) else: new_name = "static/jwks.json" f = open(new_name, "w") f.write(json.dumps(jwks)) f.close() OAS.jwks_uri.append("%s%s" % (OAS.baseurl, new_name)) for b in OAS.keyjar[""]: LOGGER.info("OC3 server keys: %s" % b) # Setup the web server SRV = wsgiserver.CherryPyWSGIServer(('0.0.0.0', args.port), application) https = "" if config.SERVICE_URL.startswith("https"): https = "using HTTPS" SRV.ssl_adapter = ssl_builtin.BuiltinSSLAdapter( config.SERVER_CERT, config.SERVER_KEY, config.CERT_CHAIN) LOGGER.info("OC server starting listening on port:%s %s" % (args.port, https)) print "OC server starting listening on port:%s %s" % (args.port, https) try: SRV.start() except KeyboardInterrupt: SRV.stop()