Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit fc3ece1

Browse files
[client] Adapt starting with no SSL + uvicorn logging
1 parent becfd6a commit fc3ece1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def __init__(
230230
connector_config: Dict,
231231
applicant_id,
232232
listen_protocol,
233+
listen_protocol_api_ssl,
233234
listen_protocol_api_path,
234235
listen_protocol_api_port,
235236
callback,
@@ -244,6 +245,7 @@ def __init__(
244245
self.config = config
245246
self.opencti_token = opencti_token
246247
self.listen_protocol = listen_protocol
248+
self.listen_protocol_api_ssl = listen_protocol_api_ssl
247249
self.listen_protocol_api_path = listen_protocol_api_path
248250
self.listen_protocol_api_port = listen_protocol_api_port
249251
self.connector_applicant_id = applicant_id
@@ -501,15 +503,22 @@ def run(self) -> None:
501503
# Wait some time and then retry ListenQueue again.
502504
time.sleep(10)
503505
elif self.listen_protocol == "API":
506+
self.helper.connector_logger.info("Starting Listen HTTP thread")
504507
app.add_api_route(
505508
self.listen_protocol_api_path, self._process_callback, methods=["POST"]
506509
)
507-
ssl_ctx = create_callback_ssl_context(self.config)
508510
config = uvicorn.Config(
509-
app, host="0.0.0.0", port=self.listen_protocol_api_port, reload=False
511+
app,
512+
host="0.0.0.0",
513+
port=self.listen_protocol_api_port,
514+
reload=False,
515+
log_config=None,
516+
log_level=None,
510517
)
511518
config.load() # Manually calling the .load() to trigger needed actions outside HTTPS
512-
config.ssl = ssl_ctx
519+
if self.listen_protocol_api_ssl:
520+
ssl_ctx = create_callback_ssl_context(self.config)
521+
config.ssl = ssl_ctx
513522
server = uvicorn.Server(config)
514523
server.run()
515524

@@ -1578,6 +1587,7 @@ def listen(
15781587
self.connector_config,
15791588
self.applicant_id,
15801589
self.listen_protocol,
1590+
self.listen_protocol_api_ssl,
15811591
self.listen_protocol_api_path,
15821592
self.listen_protocol_api_port,
15831593
message_callback,

0 commit comments

Comments
 (0)