Skip to content

Commit 87b75b0

Browse files
authored
Merge pull request #14 from bcmi-labs/load_creds
ucloud: Support loading DER key/cert from path passed in ssl_params.
2 parents 7e73472 + 4adc0ae commit 87b75b0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arduino_iot_cloud/ucloud.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ def __init__(
183183
self.last_ping = timestamp()
184184
self.device_topic = b"/a/d/" + device_id + b"/e/i"
185185
self.senmlpack = SenmlPack("", self.senml_generic_callback)
186+
if "keyfile" in ssl_params and "der" in ssl_params["keyfile"]:
187+
# MicroPython does not support secure elements yet, and key/cert
188+
# must be loaded from DER files and passed as binary blobs.
189+
with open(ssl_params.pop("keyfile"), "rb") as f:
190+
ssl_params["key"] = f.read()
191+
with open(ssl_params.pop("certfile"), "rb") as f:
192+
ssl_params["cert"] = f.read()
186193
self.mqtt = MQTTClient(device_id, server, port, ssl_params, username, password, keepalive, self.mqtt_callback)
187194
# Note: the following internal objects are initialized by the cloud.
188195
for name in ["thing_id", "tz_offset", "tz_dst_until"]:

0 commit comments

Comments
 (0)