8
8
import asyncio
9
9
from arduino_iot_cloud import ArduinoCloudClient
10
10
from arduino_iot_cloud import Task
11
+ from arduino_iot_cloud import CADATA # noqa
11
12
import argparse
12
13
13
14
@@ -47,6 +48,9 @@ def wdt_task(client, args, ts=[None]):
47
48
parser .add_argument (
48
49
"-f" , "--file-auth" , action = "store_true" , help = "Use key/cert files"
49
50
)
51
+ parser .add_argument (
52
+ "-ca" , "--ca-data" , action = "store_true" , help = "Use key/cert files and CADATA"
53
+ )
50
54
parser .add_argument (
51
55
"-s" , "--sync" , action = "store_true" , help = "Run in synchronous mode"
52
56
)
@@ -76,12 +80,14 @@ def wdt_task(client, args, ts=[None]):
76
80
elif args .file_auth :
77
81
import ssl
78
82
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 } "
79
85
client = ArduinoCloudClient (
80
86
device_id = os .getenv ("DEVICE_ID" ),
81
87
ssl_params = {
82
88
"keyfile" : f"key.{ fmt } " ,
83
89
"certfile" : f"cert.{ fmt } " ,
84
- "ca_certs" : f"ca-root. { fmt } " ,
90
+ ca_key : ca_val ,
85
91
"cert_reqs" : ssl .CERT_REQUIRED ,
86
92
},
87
93
sync_mode = args .sync ,
@@ -95,7 +101,7 @@ def wdt_task(client, args, ts=[None]):
95
101
"use_hsm" : True ,
96
102
"keyfile" : "pkcs11:token=arduino" ,
97
103
"certfile" : "pkcs11:token=arduino" ,
98
- "ca_certs " : "ca-root.pem" ,
104
+ "cafile " : "ca-root.pem" ,
99
105
"cert_reqs" : ssl .CERT_REQUIRED ,
100
106
"engine_path" : "/lib/x86_64-linux-gnu/engines-3/libpkcs11.so" ,
101
107
"module_path" : "/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so" ,
0 commit comments