@@ -60,6 +60,7 @@ def _setup():
6060 "name" : "stream" ,
6161 "listen_host" : cfg .CONF .stream .host ,
6262 "listen_port" : cfg .CONF .stream .port ,
63+ "listen_ssl" : cfg .CONF .stream .use_ssl ,
6364 "type" : "active" ,
6465 }
6566 common_setup (
@@ -78,15 +79,34 @@ def _setup():
7879def _run_server ():
7980 host = cfg .CONF .stream .host
8081 port = cfg .CONF .stream .port
82+ use_ssl = cfg .CONF .stream .use_ssl
83+
84+ cert_file_path = os .path .realpath (cfg .CONF .stream .cert )
85+ key_file_path = os .path .realpath (cfg .CONF .stream .key )
86+
87+ if use_ssl and not os .path .isfile (cert_file_path ):
88+ raise ValueError ('Certificate file "%s" doesn\' t exist' % (cert_file_path ))
89+
90+ if use_ssl and not os .path .isfile (key_file_path ):
91+ raise ValueError ('Private key file "%s" doesn\' t exist' % (key_file_path ))
8192
8293 LOG .info (
83- "(PID=%s) ST2 Stream API is serving on http://%s:%s." , os .getpid (), host , port
94+ "(PID=%s) ST2 Stream API is serving on %s://%s:%s." ,
95+ os .getpid (),
96+ "https" if use_ssl else "http" ,
97+ host ,
98+ port ,
8499 )
85100
86101 max_pool_size = eventlet .wsgi .DEFAULT_MAX_SIMULTANEOUS_REQUESTS
87102 worker_pool = eventlet .GreenPool (max_pool_size )
88103 sock = eventlet .listen ((host , port ))
89104
105+ if use_ssl :
106+ sock = eventlet .wrap_ssl (
107+ sock , certfile = cert_file_path , keyfile = key_file_path , server_side = True
108+ )
109+
90110 def queue_shutdown (signal_number , stack_frame ):
91111 deregister_service (STREAM )
92112 eventlet .spawn_n (
0 commit comments