Skip to content

Commit 2c21178

Browse files
committed
Adding a PROGMEM version of setRootCA
1 parent 141e260 commit 2c21178

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ bool HTTPClient::setRootCA(uint8_t * cert, size_t size)
376376
return result;
377377
}
378378

379+
bool HTTPClient::setRootCA_P(PGM_VOID_P * cert, size_t size)
380+
{
381+
bool result = false;
382+
if(_tcp && (_protocol == "https" || _port == 443)) {
383+
auto client = static_cast<WiFiClientSecure*>(_tcp.get());
384+
if(client) {
385+
uint8_t* buf = new uint8_t[size];
386+
memcpy_P(buf, cert, size);
387+
result = client->setCACert(buf, size);
388+
delete[] buf;
389+
}
390+
}
391+
DEBUG_HTTPCLIENT("[HTTP-Client][setRootCA_P] Result: %d\n", (int) result);
392+
return result;
393+
}
394+
379395
bool HTTPClient::setRootCA(Stream& cert, size_t size)
380396
{
381397
bool result = false;

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ class HTTPClient
153153
// Set the root certificate authority to authorize SSL connections with. Must initialize SNTP first.
154154
bool setRootCA(uint8_t * cert, size_t size);
155155
// Set the root certificate authority to authorize SSL connections with. Must initialize SNTP first.
156+
bool setRootCA_P(PGM_VOID_P * cert, size_t size);
157+
// Set the root certificate authority to authorize SSL connections with. Must initialize SNTP first.
156158
bool setRootCA(Stream& cert, size_t size);
157159

158160
void useHTTP10(bool usehttp10 = true);

0 commit comments

Comments
 (0)