Skip to content

Commit bc4600e

Browse files
committed
Added ESP32 WiFiClientSecure::setCACertBundle().
WiFiClientSecure can now use a bundle of certificates to authenticate a server. See espressif/arduino-esp32#6106
1 parent 0d5fced commit bc4600e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Diff for: src/Tiny_Websockets_Generic/client.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ namespace websockets2_generic
169169
//////
170170
#elif defined(ESP32)
171171
void setCACert(const char* ca_cert);
172+
void setCACertBundle(const uint8_t* ca_cert_bundle);
172173
void setCertificate(const char* client_ca);
173174
void setPrivateKey(const char* private_key);
174175
#endif
@@ -211,6 +212,7 @@ namespace websockets2_generic
211212
//////
212213
#elif defined(ESP32)
213214
const char* _optional_ssl_ca_cert = nullptr;
215+
const uint8_t* _optional_ssl_ca_cert_bundle = nullptr;
214216
const char* _optional_ssl_client_ca = nullptr;
215217
const char* _optional_ssl_private_key = nullptr;
216218
#endif

Diff for: src/Tiny_Websockets_Generic/network/esp32/esp32_tcp.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ namespace websockets2_generic
4848
this->client.setCACert(ca_cert);
4949
}
5050

51+
void setCACertBundle(const uint8_t* ca_cert_bundle)
52+
{
53+
this->client.setCACertBundle(ca_cert_bundle);
54+
}
55+
5156
void setCertificate(const char* client_ca)
5257
{
5358
this->client.setCertificate(client_ca);

Diff for: src/WebSockets2_Generic_Client.hpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,19 @@ namespace websockets2_generic
458458

459459
#elif defined(ESP32)
460460

461-
if (this->_optional_ssl_ca_cert || this->_optional_ssl_client_ca || this->_optional_ssl_private_key)
461+
if (this->_optional_ssl_ca_cert || this->_optional_ssl_ca_cert_bundle ||
462+
this->_optional_ssl_client_ca || this->_optional_ssl_private_key)
462463
{
463464
if (this->_optional_ssl_ca_cert)
464465
{
465466
client->setCACert(this->_optional_ssl_ca_cert);
466467
}
467468

469+
if (this->_optional_ssl_ca_cert_bundle)
470+
{
471+
client->setCACertBundle(this->_optional_ssl_ca_cert_bundle);
472+
}
473+
468474
if (this->_optional_ssl_client_ca)
469475
{
470476
client->setCertificate(this->_optional_ssl_client_ca);
@@ -1119,6 +1125,13 @@ namespace websockets2_generic
11191125

11201126
/////////////////////////////////////////////////////////
11211127

1128+
void WebsocketsClient::setCACertBundle(const uint8_t* ca_cert_bundle)
1129+
{
1130+
this->_optional_ssl_ca_cert_bundle = ca_cert_bundle;
1131+
}
1132+
1133+
/////////////////////////////////////////////////////////
1134+
11221135
void WebsocketsClient::setCertificate(const char* client_ca)
11231136
{
11241137
this->_optional_ssl_client_ca = client_ca;
@@ -1136,6 +1149,7 @@ namespace websockets2_generic
11361149
void WebsocketsClient::setInsecure()
11371150
{
11381151
this->_optional_ssl_ca_cert = nullptr;
1152+
this->_optional_ssl_ca_cert_bundle = nullptr;
11391153
this->_optional_ssl_client_ca = nullptr;
11401154
this->_optional_ssl_private_key = nullptr;
11411155
}

0 commit comments

Comments
 (0)