From d96a8a49c4f074e2cd8273fead18766162219540 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 27 Apr 2023 12:52:09 +0200 Subject: [PATCH] ussl: Fix basic authentication mode on Linux. * Fallback to Python's SSL to wrap sockets if key and certificate files/arguments are not provided. --- src/arduino_iot_cloud/ussl.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/arduino_iot_cloud/ussl.py b/src/arduino_iot_cloud/ussl.py index 52eeded..1c5a667 100644 --- a/src/arduino_iot_cloud/ussl.py +++ b/src/arduino_iot_cloud/ussl.py @@ -32,15 +32,20 @@ def init(pin, certfile, keyfile, engine_path, module_path): def wrap_socket( sock_in, - pin, - certfile, - keyfile, + pin=None, + certfile=None, + keyfile=None, ca_certs=None, cert_reqs=CERT_NONE, ciphers=None, engine_path=_ENGINE_PATH, module_path=_MODULE_PATH, ): + if certfile is None or keyfile is None: + # Fallback to Python's SSL + import ssl + return ssl.wrap_socket(sock_in) + if _key is None or _cert is None: init(pin, certfile, keyfile, engine_path, module_path)