Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Added ESP32 WiFiClientSecure::setCACertBundle(). #40

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Tiny_Websockets_Generic/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace websockets2_generic
//////
#elif defined(ESP32)
void setCACert(const char* ca_cert);
void setCACertBundle(const uint8_t* ca_cert_bundle);
void setCertificate(const char* client_ca);
void setPrivateKey(const char* private_key);
#endif
Expand Down Expand Up @@ -211,6 +212,7 @@ namespace websockets2_generic
//////
#elif defined(ESP32)
const char* _optional_ssl_ca_cert = nullptr;
const uint8_t* _optional_ssl_ca_cert_bundle = nullptr;
const char* _optional_ssl_client_ca = nullptr;
const char* _optional_ssl_private_key = nullptr;
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/Tiny_Websockets_Generic/network/esp32/esp32_tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ namespace websockets2_generic
this->client.setCACert(ca_cert);
}

void setCACertBundle(const uint8_t* ca_cert_bundle)
{
this->client.setCACertBundle(ca_cert_bundle);
}

void setCertificate(const char* client_ca)
{
this->client.setCertificate(client_ca);
Expand Down
16 changes: 15 additions & 1 deletion src/WebSockets2_Generic_Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,19 @@ namespace websockets2_generic

#elif defined(ESP32)

if (this->_optional_ssl_ca_cert || this->_optional_ssl_client_ca || this->_optional_ssl_private_key)
if (this->_optional_ssl_ca_cert || this->_optional_ssl_ca_cert_bundle ||
this->_optional_ssl_client_ca || this->_optional_ssl_private_key)
{
if (this->_optional_ssl_ca_cert)
{
client->setCACert(this->_optional_ssl_ca_cert);
}

if (this->_optional_ssl_ca_cert_bundle)
{
client->setCACertBundle(this->_optional_ssl_ca_cert_bundle);
}

if (this->_optional_ssl_client_ca)
{
client->setCertificate(this->_optional_ssl_client_ca);
Expand Down Expand Up @@ -1119,6 +1125,13 @@ namespace websockets2_generic

/////////////////////////////////////////////////////////

void WebsocketsClient::setCACertBundle(const uint8_t* ca_cert_bundle)
{
this->_optional_ssl_ca_cert_bundle = ca_cert_bundle;
}

/////////////////////////////////////////////////////////

void WebsocketsClient::setCertificate(const char* client_ca)
{
this->_optional_ssl_client_ca = client_ca;
Expand All @@ -1136,6 +1149,7 @@ namespace websockets2_generic
void WebsocketsClient::setInsecure()
{
this->_optional_ssl_ca_cert = nullptr;
this->_optional_ssl_ca_cert_bundle = nullptr;
this->_optional_ssl_client_ca = nullptr;
this->_optional_ssl_private_key = nullptr;
}
Expand Down