mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
Add ESP certificate bundle feature
Adds the ESP certificate bundle feature that enables users to bundle a root certificate bundle together with their application. Default bundle includes all Mozilla root certificates Closes IDF-296
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "esp_crt_bundle.h"
|
||||
|
||||
|
||||
/* Constants that aren't configurable in menuconfig */
|
||||
@@ -61,19 +62,6 @@ static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n"
|
||||
"User-Agent: esp-idf/1.0 esp32\r\n"
|
||||
"\r\n";
|
||||
|
||||
/* Root cert for howsmyssl.com, taken from server_root_cert.pem
|
||||
|
||||
The PEM file was extracted from the output of this command:
|
||||
openssl s_client -showcerts -connect www.howsmyssl.com:443 </dev/null
|
||||
|
||||
The CA root cert is the last cert given in the chain of certs.
|
||||
|
||||
To embed it in the app binary, the PEM file is named
|
||||
in the component.mk COMPONENT_EMBED_TXTFILES variable.
|
||||
*/
|
||||
extern const uint8_t server_root_cert_pem_start[] asm("_binary_server_root_cert_pem_start");
|
||||
extern const uint8_t server_root_cert_pem_end[] asm("_binary_server_root_cert_pem_end");
|
||||
|
||||
|
||||
static void https_get_task(void *pvParameters)
|
||||
{
|
||||
@@ -102,14 +90,13 @@ static void https_get_task(void *pvParameters)
|
||||
abort();
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Loading the CA root certificate...");
|
||||
ESP_LOGI(TAG, "Attaching the certificate bundle...");
|
||||
|
||||
ret = mbedtls_x509_crt_parse(&cacert, server_root_cert_pem_start,
|
||||
server_root_cert_pem_end-server_root_cert_pem_start);
|
||||
ret = esp_crt_bundle_attach(&conf);
|
||||
|
||||
if(ret < 0)
|
||||
{
|
||||
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret);
|
||||
ESP_LOGE(TAG, "esp_crt_bundle_attach returned -0x%x\n\n", -ret);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user