esp_crt_bundle: fixes the "No CA Chain is set" error

When compiling esp_crt_bundle.c, it would end up with a different struct layout due
to configuration options from "mbedtls/esp_config.h" not being considered.

This lead to ca_chain potentially not being set correctly.
This commit is contained in:
Marius Vikhammer 2020-05-21 14:48:17 +08:00
parent 9f801fd2f5
commit f72d259622
2 changed files with 4 additions and 3 deletions

View file

@ -120,6 +120,6 @@ endif()
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls)
# Link mbedtls libraries to component library
target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets})
target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_targets})

View file

@ -196,9 +196,10 @@ esp_err_t esp_crt_bundle_attach(void *conf)
* This is only required so that the
* cacert_ptr passes non-NULL check during handshake
*/
mbedtls_ssl_config *ssl_conf = (mbedtls_ssl_config *)conf;
mbedtls_x509_crt_init(&s_dummy_crt);
((mbedtls_ssl_config *)conf)->ca_chain = &s_dummy_crt;
mbedtls_ssl_conf_verify((mbedtls_ssl_config *)conf, esp_crt_verify_callback, NULL);
mbedtls_ssl_conf_ca_chain(ssl_conf, &s_dummy_crt, NULL);
mbedtls_ssl_conf_verify(ssl_conf, esp_crt_verify_callback, NULL);
}
return ret;