@@ -68,7 +68,6 @@ void CAtHandler::add_cmds_wifi_SSL() {
6868 return chAT::CommandStatus::ERROR;
6969 }
7070
71- bool ca_root_custom = false ;
7271 int ca_root_size = 0 ;
7372 if (parser.args .size () >= 2 ){
7473 auto &ca_root_size_str = parser.args [1 ];
@@ -80,8 +79,6 @@ void CAtHandler::add_cmds_wifi_SSL() {
8079 }
8180
8281 if (ca_root_custom) {
83-
84-
8582 cert_buf = srv.inhibit_read (ca_root_size);
8683 size_t offset = cert_buf.size ();
8784
@@ -204,6 +201,8 @@ void CAtHandler::add_cmds_wifi_SSL() {
204201 /* Set client key */
205202 the_client.sslclient ->setPrivateKey ((const char *)client_key_pem.data ());
206203
204+ client_cert = true ;
205+
207206 return chAT::CommandStatus::OK;
208207 }
209208 default :
@@ -277,6 +276,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
277276 return chAT::CommandStatus::ERROR;
278277 }
279278
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+
280292 if (!the_client.sslclient ->connect (host.c_str (), atoi (port.c_str ()))) {
281293 return chAT::CommandStatus::ERROR;
282294 }
@@ -326,6 +338,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
326338 return chAT::CommandStatus::ERROR;
327339 }
328340
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+
329354 if (!the_client.sslclient ->connect (address, atoi (hostport.c_str ()))) {
330355 return chAT::CommandStatus::ERROR;
331356 }
@@ -381,6 +406,19 @@ void CAtHandler::add_cmds_wifi_SSL() {
381406 }
382407 }
383408
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+
384422 if (!the_client.sslclient ->connect (host.c_str (), atoi (port.c_str ()), timeout)) {
385423 return chAT::CommandStatus::ERROR;
386424 }
0 commit comments