@@ -30,7 +30,14 @@ void WiFiSSLClient::getSocket() {
3030int WiFiSSLClient::connect (IPAddress ip, uint16_t port) {
3131/* -------------------------------------------------------------------------- */
3232 getSocket ();
33-
33+ if (_root_ca != nullptr ) {
34+ setCACert (_root_ca);
35+ } else {
36+ setCACert ();
37+ }
38+ if ((_ecc_slot != -1 ) && (_ecc_cert != nullptr ) && (_ecc_cert_len != 0 )) {
39+ setEccSlot (_ecc_slot, _ecc_cert, _ecc_cert_len);
40+ }
3441 string res = " " ;
3542 if (modem.write (string (PROMPT (_SSLCLIENTCONNECTIP)),res, " %s%d,%s,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECTIP), _sock, ip.toString (), port)) {
3643 return 1 ;
@@ -42,9 +49,14 @@ int WiFiSSLClient::connect(IPAddress ip, uint16_t port) {
4249int WiFiSSLClient::connect (const char * host, uint16_t port) {
4350/* -------------------------------------------------------------------------- */
4451 getSocket ();
45- if (!_custom_root) {
52+ if (_root_ca != nullptr ) {
53+ setCACert (_root_ca);
54+ } else {
4655 setCACert ();
4756 }
57+ if ((_ecc_slot != -1 ) && (_ecc_cert != nullptr ) && (_ecc_cert_len != 0 )) {
58+ setEccSlot (_ecc_slot, _ecc_cert, _ecc_cert_len);
59+ }
4860 string res = " " ;
4961 if (modem.write (string (PROMPT (_SSLCLIENTCONNECTNAME)),res, " %s%d,%s,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECTNAME), _sock, host, port)) {
5062 return 1 ;
@@ -60,7 +72,7 @@ void WiFiSSLClient::setCACert(const char* root_ca, size_t size) {
6072 if (size > 0 ) {
6173 modem.write_nowait (string (PROMPT (_SETCAROOT)),res, " %s%d,%d\r\n " , CMD_WRITE (_SETCAROOT), _sock, size);
6274 if (modem.passthrough ((uint8_t *)root_ca, size)) {
63- _custom_root = true ;
75+ _root_ca = root_ca ;
6476 }
6577 } else {
6678 modem.write (string (PROMPT (_SETCAROOT)),res, " %s%d\r\n " , CMD_WRITE (_SETCAROOT), _sock);
@@ -75,6 +87,9 @@ void WiFiSSLClient::setEccSlot(int ecc508KeySlot, const byte cert[], int certLen
7587 if (certLength > 0 ) {
7688 modem.write_nowait (string (PROMPT (_SETECCSLOT)),res, " %s%d,%d,%d\r\n " , CMD_WRITE (_SETECCSLOT), _sock, ecc508KeySlot, certLength);
7789 modem.passthrough ((uint8_t *)cert, certLength);
90+ _ecc_slot = ecc508KeySlot;
91+ _ecc_cert = cert;
92+ _ecc_cert_len = certLength;
7893 }
7994}
8095
0 commit comments