Skip to content

Commit 6b85a36

Browse files
committed
Experiement with global CA store
1 parent 441688f commit 6b85a36

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/http/HTTPClientState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ HTTP::HTTPClientState::HTTPClientState(const char* url, uint32_t timeoutMs)
3232
cfg.transport_type = HTTP_TRANSPORT_OVER_SSL;
3333
cfg.user_data = reinterpret_cast<void*>(this);
3434
cfg.is_async = false;
35-
cfg.use_global_ca_store = false;
35+
cfg.use_global_ca_store = true;
3636

3737
m_handle = esp_http_client_init(&cfg);
3838
}

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const char* const TAG = "main";
1919

2020
#include <Arduino.h>
2121

22+
#include <esp_tls.h>
23+
2224
#include <memory>
2325

2426
// Internal setup function, returns true if setup succeeded, false otherwise.
@@ -89,11 +91,17 @@ void appSetup()
8991
}
9092
}
9193

94+
extern const uint8_t* global_ca_crt_bundle_start asm("_binary_certificates_x509_crt_bundle_start");
95+
extern const uint8_t* global_ca_crt_bundle_end asm("_binary_certificates_x509_crt_bundle_end");
96+
9297
// Arduino setup function
9398
void setup()
9499
{
95100
::Serial.begin(115'200);
96101

102+
esp_tls_init_global_ca_store();
103+
esp_tls_set_global_ca_store(global_ca_crt_bundle_start, static_cast<uint32_t>(global_ca_crt_bundle_end - global_ca_crt_bundle_start));
104+
97105
OpenShock::Config::Init();
98106

99107
if (!OpenShock::Events::Init()) {

0 commit comments

Comments
 (0)