@@ -30,7 +30,14 @@ void WiFiSSLClient::getSocket() {
30
30
int WiFiSSLClient::connect (IPAddress ip, uint16_t port) {
31
31
/* -------------------------------------------------------------------------- */
32
32
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
+ }
34
41
string res = " " ;
35
42
if (modem.write (string (PROMPT (_SSLCLIENTCONNECTIP)),res, " %s%d,%s,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECTIP), _sock, ip.toString (), port)) {
36
43
return 1 ;
@@ -42,9 +49,14 @@ int WiFiSSLClient::connect(IPAddress ip, uint16_t port) {
42
49
int WiFiSSLClient::connect (const char * host, uint16_t port) {
43
50
/* -------------------------------------------------------------------------- */
44
51
getSocket ();
45
- if (!_custom_root) {
52
+ if (_root_ca != nullptr ) {
53
+ setCACert (_root_ca);
54
+ } else {
46
55
setCACert ();
47
56
}
57
+ if ((_ecc_slot != -1 ) && (_ecc_cert != nullptr ) && (_ecc_cert_len != 0 )) {
58
+ setEccSlot (_ecc_slot, _ecc_cert, _ecc_cert_len);
59
+ }
48
60
string res = " " ;
49
61
if (modem.write (string (PROMPT (_SSLCLIENTCONNECTNAME)),res, " %s%d,%s,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECTNAME), _sock, host, port)) {
50
62
return 1 ;
@@ -60,7 +72,7 @@ void WiFiSSLClient::setCACert(const char* root_ca, size_t size) {
60
72
if (size > 0 ) {
61
73
modem.write_nowait (string (PROMPT (_SETCAROOT)),res, " %s%d,%d\r\n " , CMD_WRITE (_SETCAROOT), _sock, size);
62
74
if (modem.passthrough ((uint8_t *)root_ca, size)) {
63
- _custom_root = true ;
75
+ _root_ca = root_ca ;
64
76
}
65
77
} else {
66
78
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
75
87
if (certLength > 0 ) {
76
88
modem.write_nowait (string (PROMPT (_SETECCSLOT)),res, " %s%d,%d,%d\r\n " , CMD_WRITE (_SETECCSLOT), _sock, ecc508KeySlot, certLength);
77
89
modem.passthrough ((uint8_t *)cert, certLength);
90
+ _ecc_slot = ecc508KeySlot;
91
+ _ecc_cert = cert;
92
+ _ecc_cert_len = certLength;
78
93
}
79
94
}
80
95
0 commit comments