88import asyncio
99from arduino_iot_cloud import ArduinoCloudClient
1010from arduino_iot_cloud import Task
11+ from arduino_iot_cloud import CADATA # noqa
1112import argparse
1213
1314
@@ -47,6 +48,9 @@ def wdt_task(client, args, ts=[None]):
4748 parser .add_argument (
4849 "-f" , "--file-auth" , action = "store_true" , help = "Use key/cert files"
4950 )
51+ parser .add_argument (
52+ "-ca" , "--ca-data" , action = "store_true" , help = "Use embedded CADATA"
53+ )
5054 parser .add_argument (
5155 "-s" , "--sync" , action = "store_true" , help = "Run in synchronous mode"
5256 )
@@ -76,12 +80,14 @@ def wdt_task(client, args, ts=[None]):
7680 elif args .file_auth :
7781 import ssl
7882 fmt = "der" if sys .implementation .name == "micropython" else "pem"
83+ ca_key = "cadata" if args .ca_data else "cafile"
84+ ca_val = CADATA if args .ca_data else f"ca-root.{ fmt } "
7985 client = ArduinoCloudClient (
8086 device_id = os .getenv ("DEVICE_ID" ),
8187 ssl_params = {
8288 "keyfile" : f"key.{ fmt } " ,
8389 "certfile" : f"cert.{ fmt } " ,
84- "ca_certs" : f"ca-root. { fmt } " ,
90+ ca_key : ca_val ,
8591 "cert_reqs" : ssl .CERT_REQUIRED ,
8692 },
8793 sync_mode = args .sync ,
@@ -95,7 +101,7 @@ def wdt_task(client, args, ts=[None]):
95101 "use_hsm" : True ,
96102 "keyfile" : "pkcs11:token=arduino" ,
97103 "certfile" : "pkcs11:token=arduino" ,
98- "ca_certs " : "ca-root.pem" ,
104+ "cafile " : "ca-root.pem" ,
99105 "cert_reqs" : ssl .CERT_REQUIRED ,
100106 "engine_path" : "/lib/x86_64-linux-gnu/engines-3/libpkcs11.so" ,
101107 "module_path" : "/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so" ,
0 commit comments