Skip to content

Commit c409560

Browse files
committed
wifi ssl: allow memory mapping of cert partition from non 64K aligned address
1 parent 0a378b6 commit c409560

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

UNOR4USBBridge/at_handler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class CAtHandler {
7474
std::unordered_map<std::string, std::function<chAT::CommandStatus(chAT::Server&, chAT::ATParser&)>> command_table;
7575
chAT::Server at_srv;
7676
HardwareSerial *serial;
77+
uint8_t* cert_in_flash_ptr = nullptr;
78+
spi_flash_mmap_handle_t cert_in_flash_handle;
7779

7880
CClientWrapper getClient(int sock);
7981

UNOR4USBBridge/cmds_wifi_SSL.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ void CAtHandler::add_cmds_wifi_SSL() {
101101
#ifdef BUNDLED_CA_ROOT_CRT
102102
the_client.sslclient->setCACertBundle((const uint8_t *)x509_crt_bundle_data);
103103
#else
104-
const uint8_t* cert_in_flash;
105-
static spi_flash_mmap_handle_t t;
106-
spi_flash_mmap(ROOT_CERTIFICATES_ADDRESS, 128*1024, SPI_FLASH_MMAP_DATA, (const void**)&cert_in_flash, &t);
107-
the_client.sslclient->setCACertBundle((const uint8_t *)cert_in_flash);
104+
if(cert_in_flash_ptr == nullptr) {
105+
const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "cert");
106+
if(partition != nullptr) {
107+
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, (const void**)&cert_in_flash_ptr, &cert_in_flash_handle);
108+
}
109+
}
110+
111+
if(cert_in_flash_ptr != nullptr) {
112+
the_client.sslclient->setCACertBundle(cert_in_flash_ptr);
113+
}
108114
#endif
109115
srv.write_response_prompt();
110116
}

0 commit comments

Comments
 (0)