From ee433c36df042ccf50790de191224a38577ce4ea Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Jul 2023 15:12:29 +0100 Subject: [PATCH 1/2] fix pointer cast + condition --- components/esp-tls/esp_tls_mbedtls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp-tls/esp_tls_mbedtls.c b/components/esp-tls/esp_tls_mbedtls.c index 9168012f452a..238f5be975df 100644 --- a/components/esp-tls/esp_tls_mbedtls.c +++ b/components/esp-tls/esp_tls_mbedtls.c @@ -973,8 +973,8 @@ static esp_err_t esp_set_atecc608a_pki_context(esp_tls_t *tls, const void *pki) } mbedtls_x509_crt_init(&tls->clientcert); - if(cfg->clientcert_buf != NULL) { - ret = mbedtls_x509_crt_parse(&tls->clientcert, (const unsigned char*)((esp_tls_pki_t *)pki->publiccert_pem_buf), (esp_tls_pki_t *)pki->publiccert_pem_bytes); + if(((esp_tls_pki_t *)pki)->publiccert_pem_buf != NULL) { + ret = mbedtls_x509_crt_parse(&tls->clientcert, (const unsigned char*)(((esp_tls_pki_t *) pki)->publiccert_pem_buf), ((esp_tls_pki_t *)pki)->publiccert_pem_bytes); if (ret < 0) { ESP_LOGE(TAG, "mbedtls_x509_crt_parse of client cert returned -0x%04X", -ret); mbedtls_print_error_msg(ret); From 34307789300404c9268e1177d66d3291589ba011 Mon Sep 17 00:00:00 2001 From: Alex <113676765+alexxmos@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:27:13 +0100 Subject: [PATCH 2/2] Update components/esp-tls/esp_tls_mbedtls.c formatting Co-authored-by: Aditya Patwardhan --- components/esp-tls/esp_tls_mbedtls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp-tls/esp_tls_mbedtls.c b/components/esp-tls/esp_tls_mbedtls.c index 238f5be975df..7aec64a651ed 100644 --- a/components/esp-tls/esp_tls_mbedtls.c +++ b/components/esp-tls/esp_tls_mbedtls.c @@ -973,7 +973,7 @@ static esp_err_t esp_set_atecc608a_pki_context(esp_tls_t *tls, const void *pki) } mbedtls_x509_crt_init(&tls->clientcert); - if(((esp_tls_pki_t *)pki)->publiccert_pem_buf != NULL) { + if (((esp_tls_pki_t *)pki)->publiccert_pem_buf != NULL) { ret = mbedtls_x509_crt_parse(&tls->clientcert, (const unsigned char*)(((esp_tls_pki_t *) pki)->publiccert_pem_buf), ((esp_tls_pki_t *)pki)->publiccert_pem_bytes); if (ret < 0) { ESP_LOGE(TAG, "mbedtls_x509_crt_parse of client cert returned -0x%04X", -ret);