def make_server(host_port, handler, state): app = http_app.HTTPApp(state) application = oauth_middleware.OAuthMiddleware(app, None) application.get_oauth_data_store = lambda: tests.testingOAuthStore from OpenSSL import SSL cert_file = os.path.join(os.path.dirname(__file__), 'testing-certs', 'testing.cert') key_file = os.path.join(os.path.dirname(__file__), 'testing-certs', 'testing.key') ssl_context = SSL.Context(SSL.SSLv23_METHOD) ssl_context.use_privatekey_file(key_file) ssl_context.use_certificate_chain_file(cert_file) srv = httpserver.WSGIServerBase(application, host_port, handler, ssl_context=ssl_context) # workaround apparent interface mismatch orig_shutdown_request = srv.shutdown_request def shutdown_request(req): req.shutdown() srv.close_request(req) srv.shutdown_request = shutdown_request application.base_url = "https://localhost:%s" % srv.server_address[1] return srv
def make_server(host_port, application): from OpenSSL import SSL cert_file = os.path.join(os.path.dirname(__file__), 'testing-certs', 'testing.cert') key_file = os.path.join(os.path.dirname(__file__), 'testing-certs', 'testing.key') ssl_context = SSL.Context(SSL.SSLv23_METHOD) ssl_context.use_privatekey_file(key_file) ssl_context.use_certificate_chain_file(cert_file) srv = httpserver.WSGIServerBase(application, host_port, httpserver.WSGIHandler, ssl_context=ssl_context) def shutdown_request(req): req.shutdown() srv.close_request(req) srv.shutdown_request = shutdown_request return srv, "https://localhost:%s" % srv.server_address[1]