Simplify mTLS handling in tellupdater by consolidating certificate paths and streamlining HTTP/HTTPS logic.
This commit is contained in:
+10
-17
@@ -42,25 +42,18 @@ def listen_to_sse():
|
||||
while True:
|
||||
try:
|
||||
print(f"[SSE][INFO] Attempting to connect to {sse_url}...")
|
||||
|
||||
# --- MANDATORY mTLS FOR mx-db-01 ---
|
||||
import requests
|
||||
# --- FIX: Only use certs for HTTPS (DB) connections ---
|
||||
if sse_url.startswith("https:"):
|
||||
cert_pair = (
|
||||
"/etc/ssl/certs/secrets/mx-x10sa-queue-01.crt",
|
||||
"/etc/ssl/certs/secrets/mx-x10sa-queue-01.key"
|
||||
)
|
||||
# Use the combined bundle (Intermediate + Root) if you made it
|
||||
ca_root = "/etc/ssl/certs/secrets/mx-db-01_DigiCert_Global_Root_G2.pem"
|
||||
if sse_url.startswith("https://mx-db-01"):
|
||||
# mTLS path
|
||||
import requests
|
||||
cert_pair = ("/etc/ssl/certs/secrets/mx-x10sa-queue-01_from_db-01.crt", "/etc/ssl/certs/secrets/mx-x10sa-queue-01_from_db-01.key")
|
||||
ca_root = "/etc/ssl/certs/secrets/mx-db-01_Full_Chain_CA.pem"
|
||||
response = requests.get(sse_url, stream=True, cert=cert_pair, verify=ca_root)
|
||||
response.raise_for_status()
|
||||
client = sseclient.SSEClient(response)
|
||||
else:
|
||||
# Robot connection (PC17488): No certs allowed on plain HTTP
|
||||
response = requests.get(sse_url, stream=True)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
client = sseclient.SSEClient(response)
|
||||
# Robot path (PC17488) - Pass URL STRING directly
|
||||
# SSEClient will handle the simple HTTP GET itself
|
||||
client = sseclient.SSEClient(sse_url)
|
||||
|
||||
print("[SSE][listen_to_sse] Initial detected pucks fetch on connect")
|
||||
handle_tell_change_event()
|
||||
|
||||
Reference in New Issue
Block a user