mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 17:41:58 -06:00
Fix Socket.IO TLS kwargs for legacy client
This commit is contained in:
@@ -845,34 +845,43 @@ class AgentHttpClient:
|
|||||||
connect_kwargs: Dict[str, Any] = {}
|
connect_kwargs: Dict[str, Any] = {}
|
||||||
try:
|
try:
|
||||||
verify = getattr(self.session, "verify", True)
|
verify = getattr(self.session, "verify", True)
|
||||||
|
ssl_value: Any
|
||||||
context = None
|
context = None
|
||||||
if isinstance(verify, str) and os.path.isfile(verify):
|
|
||||||
|
if isinstance(verify, bool):
|
||||||
|
ssl_value = verify
|
||||||
|
elif isinstance(verify, str) and os.path.isfile(verify):
|
||||||
try:
|
try:
|
||||||
context = ssl.create_default_context(cafile=verify)
|
context = ssl.create_default_context(cafile=verify)
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
|
ssl_value = context
|
||||||
except Exception:
|
except Exception:
|
||||||
context = None
|
ssl_value = True
|
||||||
if context is not None:
|
else:
|
||||||
connect_kwargs["ssl_context"] = context
|
ssl_value = True
|
||||||
|
|
||||||
# The AsyncClient honours ``ssl_verify`` / ``ssl_context`` parameters
|
connect_kwargs["ssl"] = ssl_value
|
||||||
# passed to ``connect``. For compatibility with older engineio builds
|
|
||||||
# we also reflect the values onto the underlying engine instance when
|
|
||||||
# available so reconnect attempts use the same trust material.
|
|
||||||
connect_kwargs["ssl_verify"] = verify
|
|
||||||
|
|
||||||
engine = getattr(client, "eio", None)
|
engine = getattr(client, "eio", None)
|
||||||
if engine is not None:
|
if engine is not None:
|
||||||
try:
|
try:
|
||||||
engine.ssl_context = connect_kwargs.get("ssl_context")
|
setattr(engine, "ssl", ssl_value)
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
engine.ssl_verify = verify
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
if context is not None:
|
||||||
|
for attr in ("ssl_context", "ssl_verify"):
|
||||||
|
try:
|
||||||
|
setattr(engine, attr, context if attr == "ssl_context" else True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
elif isinstance(ssl_value, bool):
|
||||||
|
for attr in ("ssl_verify", "ssl_context"):
|
||||||
|
try:
|
||||||
|
setattr(engine, attr, ssl_value if attr == "ssl_verify" else None)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
connect_kwargs.setdefault("ssl_verify", True)
|
connect_kwargs.setdefault("ssl", True)
|
||||||
return connect_kwargs
|
return connect_kwargs
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user