@@ -36,9 +36,14 @@ int WiFiSSLClient::connect(IPAddress ip, uint16_t port) {
36
36
int WiFiSSLClient::connect (const char * host, uint16_t port) {
37
37
/* -------------------------------------------------------------------------- */
38
38
getSocket ();
39
- if (!_custom_root) {
39
+ if (_root_ca != nullptr ) {
40
+ setCACert (_root_ca);
41
+ } else {
40
42
setCACert ();
41
43
}
44
+ if ((_ecc_slot != -1 ) && (_ecc_cert != nullptr ) && (_ecc_cert_len != 0 )) {
45
+ setEccSlot (_ecc_slot, _ecc_cert, _ecc_cert_len);
46
+ }
42
47
string res = " " ;
43
48
if (_connectionTimeout) {
44
49
if (modem.write (string (PROMPT (_SSLCLIENTCONNECT)),res, " %s%d,%s,%d,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECT), _sock, host,port, _connectionTimeout)) {
@@ -60,7 +65,7 @@ void WiFiSSLClient::setCACert(const char* root_ca, size_t size) {
60
65
if (size > 0 ) {
61
66
modem.write_nowait (string (PROMPT (_SETCAROOT)),res, " %s%d,%d\r\n " , CMD_WRITE (_SETCAROOT), _sock, size);
62
67
if (modem.passthrough ((uint8_t *)root_ca, size)) {
63
- _custom_root = true ;
68
+ _root_ca = root_ca ;
64
69
}
65
70
} else {
66
71
modem.write (string (PROMPT (_SETCAROOT)),res, " %s%d\r\n " , CMD_WRITE (_SETCAROOT), _sock);
@@ -75,6 +80,9 @@ void WiFiSSLClient::setEccSlot(int ecc508KeySlot, const byte cert[], int certLen
75
80
if (certLength > 0 ) {
76
81
modem.write_nowait (string (PROMPT (_SETECCSLOT)),res, " %s%d,%d,%d\r\n " , CMD_WRITE (_SETECCSLOT), _sock, ecc508KeySlot, certLength);
77
82
modem.passthrough ((uint8_t *)cert, certLength);
83
+ _ecc_slot = ecc508KeySlot;
84
+ _ecc_cert = cert;
85
+ _ecc_cert_len = certLength;
78
86
}
79
87
}
80
88
0 commit comments