@@ -36,9 +36,14 @@ int WiFiSSLClient::connect(IPAddress ip, uint16_t port) {
3636int WiFiSSLClient::connect (const char * host, uint16_t port) {
3737/* -------------------------------------------------------------------------- */
3838 getSocket ();
39- if (!_custom_root) {
39+ if (_root_ca != nullptr ) {
40+ setCACert (_root_ca);
41+ } else {
4042 setCACert ();
4143 }
44+ if ((_ecc_slot != -1 ) && (_ecc_cert != nullptr ) && (_ecc_cert_len != 0 )) {
45+ setEccSlot (_ecc_slot, _ecc_cert, _ecc_cert_len);
46+ }
4247 string res = " " ;
4348 if (_connectionTimeout) {
4449 if (modem.write (string (PROMPT (_SSLCLIENTCONNECT)),res, " %s%d,%s,%d,%d\r\n " , CMD_WRITE (_SSLCLIENTCONNECT), _sock, host,port, _connectionTimeout)) {
@@ -60,13 +65,27 @@ void WiFiSSLClient::setCACert(const char* root_ca, size_t size) {
6065 if (size > 0 ) {
6166 modem.write_nowait (string (PROMPT (_SETCAROOT)),res, " %s%d,%d\r\n " , CMD_WRITE (_SETCAROOT), _sock, size);
6267 if (modem.passthrough ((uint8_t *)root_ca, size)) {
63- _custom_root = true ;
68+ _root_ca = root_ca ;
6469 }
6570 } else {
6671 modem.write (string (PROMPT (_SETCAROOT)),res, " %s%d\r\n " , CMD_WRITE (_SETCAROOT), _sock);
6772 }
6873}
6974
75+ /* -------------------------------------------------------------------------- */
76+ void WiFiSSLClient::setEccSlot (int ecc508KeySlot, const byte cert[], int certLength) {
77+ /* -------------------------------------------------------------------------- */
78+ getSocket ();
79+ string res = " " ;
80+ if (certLength > 0 ) {
81+ modem.write_nowait (string (PROMPT (_SETECCSLOT)),res, " %s%d,%d,%d\r\n " , CMD_WRITE (_SETECCSLOT), _sock, ecc508KeySlot, certLength);
82+ modem.passthrough ((uint8_t *)cert, certLength);
83+ _ecc_slot = ecc508KeySlot;
84+ _ecc_cert = cert;
85+ _ecc_cert_len = certLength;
86+ }
87+ }
88+
7089/* -------------------------------------------------------------------------- */
7190size_t WiFiSSLClient::write (uint8_t b){
7291/* -------------------------------------------------------------------------- */
0 commit comments