Merge branch 'feature/add_crt_bundle' into 'master'

Added support for certificate bundle

See merge request espressif/esp-mqtt!98
This commit is contained in:
David Čermák
2021-05-26 15:54:21 +00:00
3 changed files with 14 additions and 0 deletions

View File

@@ -78,6 +78,7 @@ typedef struct {
char *clientkey_password;
int clientkey_password_len;
bool use_global_ca_store;
esp_err_t ((*crt_bundle_attach)(void *conf));
const char *cacert_buf;
size_t cacert_bytes;
const char *clientcert_buf;
@@ -203,11 +204,21 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
if (cfg->use_global_ca_store == true) {
esp_transport_ssl_enable_global_ca_store(ssl);
} else if (cfg->crt_bundle_attach != NULL) {
#ifdef MQTT_SUPPORTED_FEATURE_CERTIFICATE_BUNDLE
esp_transport_ssl_crt_bundle_attach(ssl, cfg->crt_bundle_attach);
#else
ESP_LOGE(TAG, "Certificate bundle feature is not available in IDF version %s", IDF_VER);
goto esp_mqtt_set_transport_failed;
#endif
} else {
ESP_OK_CHECK(TAG, esp_mqtt_set_cert_key_data(ssl, MQTT_SSL_DATA_API_CA_CERT, cfg->cacert_buf, cfg->cacert_bytes),
goto esp_mqtt_set_transport_failed);
}
if (cfg->use_secure_element) {
#ifdef MQTT_SUPPORTED_FEATURE_SECURE_ELEMENT
#ifdef CONFIG_ESP_TLS_USE_SECURE_ELEMENT
@@ -491,6 +502,7 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
client->config->psk_hint_key = config->psk_hint_key;
client->config->skip_cert_common_name_check = config->skip_cert_common_name_check;
client->config->use_secure_element = config->use_secure_element;
client->config->crt_bundle_attach = config->crt_bundle_attach;
client->config->ds_data = config->ds_data;
if (config->clientkey_password && config->clientkey_password_len) {