Merge pull request #1 from 0xFEEDC0DE64/add-global-root-ca
Add support for global root CA chain
This commit is contained in:
@ -13,6 +13,7 @@
|
|||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
#include <esp_task_wdt.h>
|
#include <esp_task_wdt.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <esp_crt_bundle.h>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
@ -158,8 +159,8 @@ OtaCloudUpdateStatus EspAsyncOta::status() const
|
|||||||
return OtaCloudUpdateStatus::Idle;
|
return OtaCloudUpdateStatus::Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::expected<void, std::string> EspAsyncOta::trigger(std::string_view url, std::string_view cert_pem,
|
std::expected<void, std::string> EspAsyncOta::trigger(std::string_view url, std::string_view cert_pem, bool use_global_ca,
|
||||||
std::string_view client_key, std::string_view client_cert)
|
std::string_view client_key, std::string_view client_cert)
|
||||||
{
|
{
|
||||||
if (!m_taskHandle)
|
if (!m_taskHandle)
|
||||||
{
|
{
|
||||||
@ -184,6 +185,7 @@ std::expected<void, std::string> EspAsyncOta::trigger(std::string_view url, std:
|
|||||||
|
|
||||||
m_url = std::string{url};
|
m_url = std::string{url};
|
||||||
m_cert_pem = cert_pem;
|
m_cert_pem = cert_pem;
|
||||||
|
m_use_global_ca = use_global_ca;
|
||||||
m_client_key = client_key;
|
m_client_key = client_key;
|
||||||
m_client_cert = client_cert;
|
m_client_cert = client_cert;
|
||||||
|
|
||||||
@ -323,6 +325,12 @@ void EspAsyncOta::otaTask()
|
|||||||
}
|
}
|
||||||
config.skip_cert_common_name_check = false;
|
config.skip_cert_common_name_check = false;
|
||||||
|
|
||||||
|
if (m_use_global_ca)
|
||||||
|
{
|
||||||
|
//config.use_global_ca_store = true;
|
||||||
|
config.crt_bundle_attach = esp_crt_bundle_attach;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_client_key.empty())
|
if (!m_client_key.empty())
|
||||||
{
|
{
|
||||||
config.client_key_pem = m_client_key.data();
|
config.client_key_pem = m_client_key.data();
|
||||||
|
@ -38,7 +38,8 @@ public:
|
|||||||
const std::string &message() const { return m_message; }
|
const std::string &message() const { return m_message; }
|
||||||
const std::optional<esp_app_desc_t> &appDesc() const { return m_appDesc; }
|
const std::optional<esp_app_desc_t> &appDesc() const { return m_appDesc; }
|
||||||
OtaCloudUpdateStatus status() const;
|
OtaCloudUpdateStatus status() const;
|
||||||
std::expected<void, std::string> trigger(std::string_view url, std::string_view cert_pem, std::string_view client_key, std::string_view client_cert);
|
std::expected<void, std::string> trigger(std::string_view url, std::string_view cert_pem, bool use_global_ca,
|
||||||
|
std::string_view client_key, std::string_view client_cert);
|
||||||
std::expected<void, std::string> abort();
|
std::expected<void, std::string> abort();
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
@ -64,6 +65,7 @@ private:
|
|||||||
|
|
||||||
std::string m_url;
|
std::string m_url;
|
||||||
std::string_view m_cert_pem;
|
std::string_view m_cert_pem;
|
||||||
|
bool m_use_global_ca;
|
||||||
std::string_view m_client_key;
|
std::string_view m_client_key;
|
||||||
std::string_view m_client_cert;
|
std::string_view m_client_cert;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user