@@ -68,7 +68,6 @@ void CAtHandler::add_cmds_wifi_SSL() {
68
68
return chAT::CommandStatus::ERROR;
69
69
}
70
70
71
- bool ca_root_custom = false ;
72
71
int ca_root_size = 0 ;
73
72
if (parser.args .size () >= 2 ){
74
73
auto &ca_root_size_str = parser.args [1 ];
@@ -80,8 +79,6 @@ void CAtHandler::add_cmds_wifi_SSL() {
80
79
}
81
80
82
81
if (ca_root_custom) {
83
-
84
-
85
82
cert_buf = srv.inhibit_read (ca_root_size);
86
83
size_t offset = cert_buf.size ();
87
84
@@ -204,6 +201,8 @@ void CAtHandler::add_cmds_wifi_SSL() {
204
201
/* Set client key */
205
202
the_client.sslclient ->setPrivateKey ((const char *)client_key_pem.data ());
206
203
204
+ client_cert = true ;
205
+
207
206
return chAT::CommandStatus::OK;
208
207
}
209
208
default :
@@ -277,6 +276,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
277
276
return chAT::CommandStatus::ERROR;
278
277
}
279
278
279
+ /* Set custom root ca */
280
+ if (ca_root_custom) {
281
+ the_client.sslclient ->setCACert ((const char *)cert_buf.data ());
282
+ }
283
+ /* Default ca bundle is configured automatically on connect by the WiFiSSLClient */
284
+
285
+ if (client_cert) {
286
+ /* Set client certificate */
287
+ the_client.sslclient ->setCertificate ((const char *)client_cert_pem.data ());
288
+ /* Set client key */
289
+ the_client.sslclient ->setPrivateKey ((const char *)client_key_pem.data ());
290
+ }
291
+
280
292
if (!the_client.sslclient ->connect (host.c_str (), atoi (port.c_str ()))) {
281
293
return chAT::CommandStatus::ERROR;
282
294
}
@@ -326,6 +338,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
326
338
return chAT::CommandStatus::ERROR;
327
339
}
328
340
341
+ /* Set custom root ca */
342
+ if (ca_root_custom) {
343
+ the_client.sslclient ->setCACert ((const char *)cert_buf.data ());
344
+ }
345
+ /* Default ca bundle is configured automatically on connect by the WiFiSSLClient */
346
+
347
+ if (client_cert) {
348
+ /* Set client certificate */
349
+ the_client.sslclient ->setCertificate ((const char *)client_cert_pem.data ());
350
+ /* Set client key */
351
+ the_client.sslclient ->setPrivateKey ((const char *)client_key_pem.data ());
352
+ }
353
+
329
354
if (!the_client.sslclient ->connect (address, atoi (hostport.c_str ()))) {
330
355
return chAT::CommandStatus::ERROR;
331
356
}
@@ -381,6 +406,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
381
406
}
382
407
}
383
408
409
+ /* Set custom root ca */
410
+ if (ca_root_custom) {
411
+ the_client.sslclient ->setCACert ((const char *)cert_buf.data ());
412
+ }
413
+ /* Default ca bundle is configured automatically on connect by the WiFiSSLClient */
414
+
415
+ if (client_cert) {
416
+ /* Set client certificate */
417
+ the_client.sslclient ->setCertificate ((const char *)client_cert_pem.data ());
418
+ /* Set client key */
419
+ the_client.sslclient ->setPrivateKey ((const char *)client_key_pem.data ());
420
+ }
421
+
384
422
if (!the_client.sslclient ->connect (host.c_str (), atoi (port.c_str ()), timeout)) {
385
423
return chAT::CommandStatus::ERROR;
386
424
}
0 commit comments