def main(): options.parse_command_line() loop = tornado.ioloop.IOLoop.current() app = make_app(make_handlers(loop, options), get_app_settings(options)) ssl_ctx = get_ssl_context(options) server_settings = get_server_settings(options) app_listen(app, options.port, options.address, server_settings) if ssl_ctx: server_settings.update(ssl_options=ssl_ctx) app_listen(app, options.sslport, options.ssladdress, server_settings) loop.start()
def main(): options.parse_command_line() loop = tornado.ioloop.IOLoop.current() app = make_app(make_handlers(loop, options), get_app_settings(options)) ssl_ctx = get_ssl_context(options) kwargs = dict(xheaders=xheaders, max_body_size=max_body_size) app.listen(options.port, options.address, **kwargs) logging.info('Listening on {}:{}'.format(options.address, options.port)) if ssl_ctx: kwargs.update(ssl_options=ssl_ctx) app.listen(options.sslPort, options.sslAddress, **kwargs) logging.info('Listening on ssl {}:{}'.format(options.sslAddress, options.sslPort)) loop.start()
def main(): options.parse_command_line() loop = tornado.ioloop.IOLoop.current() app = make_app(make_handlers(loop, options), get_app_settings(options)) ssl_ctx = get_ssl_context(options) server_settings = get_server_settings(options) app.listen(options.port, options.address, **server_settings) logging.info('Listening on {}:{}'.format(options.address, options.port)) if ssl_ctx: server_settings.update(ssl_options=ssl_ctx) app.listen(options.sslport, options.ssladdress, **server_settings) logging.info('Listening on ssl {}:{}'.format(options.ssladdress, options.sslport)) loop.start()
def main(): # get ws_port and insert to sys.argv[1] which could be overrided by # following port number that user passed in ws_port = myeHandler.wsconfig_value("ws_port", "4200") sys.argv.insert(1, "--port={}".format(ws_port)) options.parse_command_line() loop = tornado.ioloop.IOLoop.current() app = make_app(make_handlers(loop, options), get_app_settings(options)) ssl_ctx = get_ssl_context(options) server_settings = get_server_settings(options) app_listen(app, options.port, options.address, server_settings) if ssl_ctx: server_settings.update(ssl_options=ssl_ctx) app_listen(app, options.sslport, options.ssladdress, server_settings) loop.start()
def test_get_ssl_context(self): options.certfile = '' options.keyfile = '' ssl_ctx = get_ssl_context(options) self.assertIsNone(ssl_ctx) options.certfile = 'provided' options.keyfile = '' with self.assertRaises(ValueError) as ctx: ssl_ctx = get_ssl_context(options) self.assertEqual('keyfile is not provided', str(ctx.exception)) options.certfile = '' options.keyfile = 'provided' with self.assertRaises(ValueError) as ctx: ssl_ctx = get_ssl_context(options) self.assertEqual('certfile is not provided', str(ctx.exception)) options.certfile = 'FileDoesNotExist' options.keyfile = make_tests_data_path('cert.key') with self.assertRaises(ValueError) as ctx: ssl_ctx = get_ssl_context(options) self.assertIn('does not exist', str(ctx.exception)) options.certfile = make_tests_data_path('cert.key') options.keyfile = 'FileDoesNotExist' with self.assertRaises(ValueError) as ctx: ssl_ctx = get_ssl_context(options) self.assertIn('does not exist', str(ctx.exception)) options.certfile = make_tests_data_path('cert.key') options.keyfile = make_tests_data_path('cert.key') with self.assertRaises(ssl.SSLError) as ctx: ssl_ctx = get_ssl_context(options) options.certfile = make_tests_data_path('cert.crt') options.keyfile = make_tests_data_path('cert.key') ssl_ctx = get_ssl_context(options) self.assertIsNotNone(ssl_ctx)