test_esp_crt_bundle.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /* SSL server using plain mbedTLS sockets
  2. *
  3. * Adapted from the ssl_server example in mbedtls.
  4. *
  5. * SPDX-FileCopyrightText: The Mbed TLS Contributors
  6. *
  7. * SPDX-License-Identifier: Apache-2.0
  8. *
  9. * SPDX-FileContributor: 2019-2022 Espressif Systems (Shanghai) CO LTD
  10. */
  11. #include "esp_err.h"
  12. #include "esp_log.h"
  13. #include "freertos/FreeRTOS.h"
  14. #include "freertos/task.h"
  15. #include "freertos/semphr.h"
  16. #include "mbedtls/entropy.h"
  17. #include "mbedtls/ctr_drbg.h"
  18. #include "mbedtls/x509.h"
  19. #include "mbedtls/ssl.h"
  20. #include "entropy_poll.h"
  21. #include "mbedtls/net_sockets.h"
  22. #include "mbedtls/error.h"
  23. #include "mbedtls/debug.h"
  24. #include "mbedtls/esp_debug.h"
  25. #include "esp_crt_bundle.h"
  26. #include "esp_random.h"
  27. #include "unity.h"
  28. #include "test_utils.h"
  29. #include "unity_test_utils.h"
  30. #define SERVER_ADDRESS "localhost"
  31. #define SERVER_PORT "4433"
  32. extern const uint8_t server_cert_chain_pem_start[] asm("_binary_server_cert_chain_pem_start");
  33. extern const uint8_t server_cert_chain_pem_end[] asm("_binary_server_cert_chain_pem_end");
  34. extern const uint8_t server_pk_start[] asm("_binary_prvtkey_pem_start");
  35. extern const uint8_t server_pk_end[] asm("_binary_prvtkey_pem_end");
  36. extern const uint8_t server_cert_bundle_start[] asm("_binary_server_cert_bundle_start");
  37. extern const uint8_t server_cert_bundle_end[] asm("_binary_server_cert_bundle_end");
  38. extern const uint8_t bad_md_crt_pem_start[] asm("_binary_bad_md_crt_pem_start");
  39. extern const uint8_t bad_md_crt_pem_end[] asm("_binary_bad_md_crt_pem_end");
  40. extern const uint8_t wrong_sig_crt_pem_start[] asm("_binary_wrong_sig_crt_esp32_com_pem_start");
  41. extern const uint8_t wrong_sig_crt_pem_end[] asm("_binary_wrong_sig_crt_esp32_com_pem_end");
  42. extern const uint8_t correct_sig_crt_pem_start[] asm("_binary_correct_sig_crt_esp32_com_pem_start");
  43. extern const uint8_t correct_sig_crt_pem_end[] asm("_binary_correct_sig_crt_esp32_com_pem_end");
  44. #define SEM_TIMEOUT 10000
  45. typedef struct {
  46. mbedtls_ssl_context ssl;
  47. mbedtls_net_context listen_fd;
  48. mbedtls_net_context client_fd;
  49. mbedtls_entropy_context entropy;
  50. mbedtls_ctr_drbg_context ctr_drbg;
  51. mbedtls_ssl_config conf;
  52. mbedtls_x509_crt cert;
  53. mbedtls_pk_context pkey;
  54. } mbedtls_endpoint_t;
  55. typedef enum {
  56. ESP_CRT_VALIDATE_UNKNOWN,
  57. ESP_CRT_VALIDATE_OK,
  58. ESP_CRT_VALIDATE_FAIL,
  59. }esp_crt_validate_res_t;
  60. int esp_crt_verify_callback(void *buf, mbedtls_x509_crt *crt, int data, uint32_t *flags);
  61. static const char *TAG = "cert_bundle_test";
  62. static volatile bool exit_flag;
  63. esp_err_t endpoint_teardown(mbedtls_endpoint_t *endpoint);
  64. static int myrand(void *rng_state, unsigned char *output, size_t len)
  65. {
  66. size_t olen;
  67. return mbedtls_hardware_poll(rng_state, output, len, &olen);
  68. }
  69. esp_err_t server_setup(mbedtls_endpoint_t *server)
  70. {
  71. int ret;
  72. mbedtls_ssl_config_init( &server->conf );
  73. #if CONFIG_MBEDTLS_DEBUG
  74. mbedtls_esp_enable_debug_log( &server->conf, CONFIG_MBEDTLS_DEBUG_LEVEL );
  75. #endif
  76. mbedtls_net_init( &server->listen_fd );
  77. mbedtls_net_init( &server->client_fd );
  78. mbedtls_ssl_init( &server->ssl );
  79. mbedtls_x509_crt_init( &server->cert );
  80. mbedtls_pk_init( &server->pkey );
  81. mbedtls_entropy_init( &server->entropy );
  82. mbedtls_ctr_drbg_init( &server->ctr_drbg );
  83. ESP_LOGI(TAG, "Loading the server cert and key");
  84. ret = mbedtls_x509_crt_parse( &server->cert, server_cert_chain_pem_start,
  85. server_cert_chain_pem_end - server_cert_chain_pem_start);
  86. if ( ret != 0 ) {
  87. ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned %d", ret );
  88. return ESP_FAIL;
  89. }
  90. ret = mbedtls_pk_parse_key( &server->pkey, (const unsigned char *)server_pk_start,
  91. server_pk_end - server_pk_start, NULL, 0, myrand, NULL );
  92. if ( ret != 0 ) {
  93. ESP_LOGE(TAG, "mbedtls_pk_parse_key returned %d", ret );
  94. return ESP_FAIL;
  95. }
  96. ESP_LOGI(TAG, "Bind on https://%s:%s/", SERVER_ADDRESS, SERVER_PORT );
  97. if ( ( ret = mbedtls_net_bind( &server->listen_fd, NULL, SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 ) {
  98. ESP_LOGE(TAG, "mbedtls_net_bind returned %d", ret );
  99. return ESP_FAIL;
  100. }
  101. mbedtls_net_set_nonblock(&server->listen_fd);
  102. ESP_LOGI(TAG, "Seeding the random number generator");
  103. if ( ( ret = mbedtls_ctr_drbg_seed( &server->ctr_drbg, mbedtls_entropy_func, &server->entropy,
  104. NULL, 0) ) != 0 ) {
  105. ESP_LOGE(TAG, "mbedtls_ctr_drbg_seed returned %d", ret );
  106. return ESP_FAIL;
  107. }
  108. ESP_LOGI(TAG, "Setting up the SSL data");
  109. if ( ( ret = mbedtls_ssl_config_defaults( &server->conf,
  110. MBEDTLS_SSL_IS_SERVER,
  111. MBEDTLS_SSL_TRANSPORT_STREAM,
  112. MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) {
  113. ESP_LOGE(TAG, "mbedtls_ssl_config_defaults returned %d", ret );
  114. return ESP_FAIL;
  115. }
  116. mbedtls_ssl_conf_rng( &server->conf, mbedtls_ctr_drbg_random, &server->ctr_drbg );
  117. if (( ret = mbedtls_ssl_conf_own_cert( &server->conf, &server->cert, &server->pkey ) ) != 0 ) {
  118. ESP_LOGE(TAG, "mbedtls_ssl_conf_own_cert returned %d", ret );
  119. return ESP_FAIL;
  120. }
  121. if (( ret = mbedtls_ssl_setup( &server->ssl, &server->conf ) ) != 0 ) {
  122. ESP_LOGE(TAG, "mbedtls_ssl_setup returned %d", ret );
  123. return ESP_FAIL;
  124. }
  125. return ESP_OK;
  126. }
  127. void server_task(void *pvParameters)
  128. {
  129. int ret;
  130. mbedtls_endpoint_t server;
  131. SemaphoreHandle_t *sema = (SemaphoreHandle_t *) pvParameters;
  132. if (server_setup(&server) != ESP_OK) {
  133. ESP_LOGE(TAG, "SSL server setup failed");
  134. goto exit;
  135. }
  136. /* Signal that server is up and hence client task can start now */
  137. xSemaphoreGive(*sema);
  138. bool connected = false;
  139. while (!exit_flag) {
  140. ret = mbedtls_net_accept( &server.listen_fd, &server.client_fd, NULL, 0, NULL );
  141. if (ret == 0) {
  142. connected = true;
  143. }
  144. if (connected) {
  145. mbedtls_ssl_set_bio( &server.ssl, &server.client_fd, mbedtls_net_send, mbedtls_net_recv, NULL );
  146. ret = mbedtls_ssl_handshake( &server.ssl );
  147. mbedtls_ssl_session_reset(&server.ssl);
  148. connected = false;
  149. }
  150. vTaskDelay(20 / portTICK_PERIOD_MS);
  151. }
  152. ESP_LOGE(TAG, "Server shutdown");
  153. exit:
  154. endpoint_teardown(&server);
  155. xSemaphoreGive(*sema);
  156. vTaskSuspend(NULL);
  157. }
  158. esp_err_t endpoint_teardown(mbedtls_endpoint_t *endpoint)
  159. {
  160. mbedtls_net_free( &endpoint->client_fd );
  161. mbedtls_net_free( &endpoint->listen_fd );
  162. mbedtls_x509_crt_free( &endpoint->cert );
  163. mbedtls_pk_free( &endpoint->pkey );
  164. mbedtls_ssl_free( &endpoint->ssl );
  165. mbedtls_ssl_config_free( &endpoint->conf );
  166. mbedtls_ctr_drbg_free( &endpoint->ctr_drbg );
  167. mbedtls_entropy_free( &endpoint->entropy );
  168. return ESP_OK;
  169. }
  170. esp_err_t client_setup(mbedtls_endpoint_t *client)
  171. {
  172. int ret;
  173. mbedtls_ssl_config_init( &client->conf );
  174. #if CONFIG_MBEDTLS_DEBUG
  175. mbedtls_esp_enable_debug_log( &client->conf, CONFIG_MBEDTLS_DEBUG_LEVEL );
  176. #endif
  177. mbedtls_net_init( &client->client_fd );
  178. mbedtls_ssl_init( &client->ssl );
  179. mbedtls_x509_crt_init( &client->cert );
  180. mbedtls_pk_init( &client->pkey );
  181. mbedtls_entropy_init( &client->entropy );
  182. mbedtls_ctr_drbg_init( &client->ctr_drbg );
  183. ESP_LOGI(TAG, "Seeding the random number generator");
  184. if ((ret = mbedtls_ctr_drbg_seed(&client->ctr_drbg, mbedtls_entropy_func, &client->entropy,
  185. NULL, 0)) != 0) {
  186. ESP_LOGE(TAG, "mbedtls_ctr_drbg_seed returned %d", ret);
  187. return ESP_FAIL;
  188. }
  189. ESP_LOGI(TAG, "Setting hostname for TLS session...");
  190. /* Hostname set here should match CN in server certificate */
  191. if ((ret = mbedtls_ssl_set_hostname(&client->ssl, SERVER_ADDRESS)) != 0) {
  192. ESP_LOGE(TAG, "mbedtls_ssl_set_hostname returned -0x%x", -ret);
  193. return ESP_FAIL;
  194. }
  195. ESP_LOGI(TAG, "Setting up the SSL/TLS structure...");
  196. if ((ret = mbedtls_ssl_config_defaults(&client->conf,
  197. MBEDTLS_SSL_IS_CLIENT,
  198. MBEDTLS_SSL_TRANSPORT_STREAM,
  199. MBEDTLS_SSL_PRESET_DEFAULT)) != 0) {
  200. ESP_LOGE(TAG, "mbedtls_ssl_config_defaults returned %d", ret);
  201. return ESP_FAIL;
  202. }
  203. mbedtls_ssl_conf_rng(&client->conf, mbedtls_ctr_drbg_random, &client->ctr_drbg);
  204. if ((ret = mbedtls_ssl_setup(&client->ssl, &client->conf)) != 0) {
  205. ESP_LOGE(TAG, "mbedtls_ssl_setup returned -0x%x", -ret);
  206. return ESP_FAIL;
  207. }
  208. return ESP_OK;
  209. }
  210. void client_task(void *pvParameters)
  211. {
  212. SemaphoreHandle_t *client_signal_sem = (SemaphoreHandle_t *) pvParameters;
  213. int ret = ESP_FAIL;
  214. mbedtls_endpoint_t client;
  215. esp_crt_validate_res_t res = ESP_CRT_VALIDATE_UNKNOWN;
  216. if (client_setup(&client) != ESP_OK) {
  217. ESP_LOGE(TAG, "SSL client setup failed");
  218. goto exit;
  219. }
  220. /* Test with default crt bundle that doesnt contain the ca crt */
  221. ESP_LOGI(TAG, "Connecting to %s:%s...", SERVER_ADDRESS, SERVER_PORT);
  222. if ((ret = mbedtls_net_connect(&client.client_fd, SERVER_ADDRESS, SERVER_PORT, MBEDTLS_NET_PROTO_TCP)) != 0) {
  223. ESP_LOGE(TAG, "mbedtls_net_connect returned -%x", -ret);
  224. goto exit;
  225. }
  226. ESP_LOGI(TAG, "Connected.");
  227. mbedtls_ssl_set_bio(&client.ssl, &client.client_fd, mbedtls_net_send, mbedtls_net_recv, NULL);
  228. ESP_LOGI(TAG, "Performing the SSL/TLS handshake with bundle that is missing the server root certificate");
  229. while ( ( ret = mbedtls_ssl_handshake( &client.ssl ) ) != 0 ) {
  230. if ( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) {
  231. printf( "mbedtls_ssl_handshake failed with -0x%x\n", -ret );
  232. break;
  233. }
  234. }
  235. ESP_LOGI(TAG, "Verifying peer X.509 certificate for bundle ...");
  236. ret = mbedtls_ssl_get_verify_result(&client.ssl);
  237. res = (ret == 0) ? ESP_CRT_VALIDATE_OK : ESP_CRT_VALIDATE_FAIL;
  238. if (res == ESP_CRT_VALIDATE_OK) {
  239. ESP_LOGI(TAG, "Certificate verification passed!");
  240. } else {
  241. ESP_LOGE(TAG, "Certificate verification failed!");
  242. }
  243. TEST_ASSERT(res == ESP_CRT_VALIDATE_FAIL);
  244. // Reset session before new connection
  245. mbedtls_ssl_close_notify(&client.ssl);
  246. mbedtls_ssl_session_reset(&client.ssl);
  247. mbedtls_net_free( &client.client_fd);
  248. /* Test with bundle that does contain the CA crt */
  249. esp_crt_bundle_attach(&client.conf);
  250. esp_crt_bundle_set(server_cert_bundle_start, server_cert_bundle_end - server_cert_bundle_start);
  251. ESP_LOGI(TAG, "Connecting to %s:%s...", SERVER_ADDRESS, SERVER_PORT);
  252. if ((ret = mbedtls_net_connect(&client.client_fd, SERVER_ADDRESS, SERVER_PORT, MBEDTLS_NET_PROTO_TCP)) != 0) {
  253. ESP_LOGE(TAG, "mbedtls_net_connect returned -%x", -ret);
  254. goto exit;
  255. }
  256. ESP_LOGI(TAG, "Connected.");
  257. mbedtls_ssl_set_bio(&client.ssl, &client.client_fd, mbedtls_net_send, mbedtls_net_recv, NULL);
  258. ESP_LOGI(TAG, "Performing the SSL/TLS handshake with bundle that is missing the server root certificate");
  259. while ( ( ret = mbedtls_ssl_handshake( &client.ssl ) ) != 0 ) {
  260. if ( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) {
  261. printf( "mbedtls_ssl_handshake failed with -0x%x\n", -ret );
  262. break;
  263. }
  264. }
  265. ESP_LOGI(TAG, "Verifying peer X.509 certificate for bundle ...");
  266. ret = mbedtls_ssl_get_verify_result(&client.ssl);
  267. res = (ret == 0) ? ESP_CRT_VALIDATE_OK : ESP_CRT_VALIDATE_FAIL;
  268. if (res == ESP_CRT_VALIDATE_OK) {
  269. ESP_LOGI(TAG, "Certificate verification passed!");
  270. } else {
  271. ESP_LOGE(TAG, "Certificate verification failed!");
  272. }
  273. TEST_ASSERT(res == ESP_CRT_VALIDATE_OK);
  274. // Reset session before new connection
  275. mbedtls_ssl_close_notify(&client.ssl);
  276. mbedtls_ssl_session_reset(&client.ssl);
  277. mbedtls_net_free( &client.client_fd);
  278. exit:
  279. mbedtls_ssl_close_notify(&client.ssl);
  280. mbedtls_ssl_session_reset(&client.ssl);
  281. esp_crt_bundle_detach(&client.conf);
  282. endpoint_teardown(&client);
  283. xSemaphoreGive(*client_signal_sem);
  284. vTaskSuspend(NULL);
  285. }
  286. TEST_CASE("custom certificate bundle", "[mbedtls]")
  287. {
  288. test_case_uses_tcpip();
  289. SemaphoreHandle_t signal_sem = xSemaphoreCreateBinary();
  290. TEST_ASSERT_NOT_NULL(signal_sem);
  291. exit_flag = false;
  292. TaskHandle_t server_task_handle;
  293. xTaskCreate(server_task, "server task", 8192, &signal_sem, 10, &server_task_handle);
  294. // Wait for the server to start up
  295. if (!xSemaphoreTake(signal_sem, SEM_TIMEOUT / portTICK_PERIOD_MS)) {
  296. TEST_FAIL_MESSAGE("signal_sem not released, server start failed");
  297. }
  298. SemaphoreHandle_t client_signal_sem = xSemaphoreCreateBinary();
  299. TEST_ASSERT_NOT_NULL(client_signal_sem);
  300. TaskHandle_t client_task_handle;
  301. xTaskCreate(client_task, "client task", 8192, &client_signal_sem, 10, &client_task_handle);
  302. if (!xSemaphoreTake(client_signal_sem, SEM_TIMEOUT / portTICK_PERIOD_MS)) {
  303. TEST_FAIL_MESSAGE("client_signal_sem not released, client exit failed");
  304. }
  305. unity_utils_task_delete(client_task_handle);
  306. exit_flag = true;
  307. if (!xSemaphoreTake(signal_sem, SEM_TIMEOUT / portTICK_PERIOD_MS)) {
  308. TEST_FAIL_MESSAGE("signal_sem not released, server exit failed");
  309. }
  310. unity_utils_task_delete(server_task_handle);
  311. vSemaphoreDelete(client_signal_sem);
  312. vSemaphoreDelete(signal_sem);
  313. }
  314. TEST_CASE("custom certificate bundle - weak hash", "[mbedtls]")
  315. {
  316. /* A weak signature hash on the trusted certificate should not stop
  317. us from verifying the chain, since we already trust it a weak signature hash is
  318. not a security issue */
  319. mbedtls_x509_crt crt;
  320. uint32_t flags = 0;
  321. esp_crt_bundle_attach(NULL);
  322. mbedtls_x509_crt_init( &crt );
  323. mbedtls_x509_crt_parse(&crt, bad_md_crt_pem_start, bad_md_crt_pem_end - bad_md_crt_pem_start);
  324. TEST_ASSERT(mbedtls_x509_crt_verify(&crt, NULL, NULL, NULL, &flags, esp_crt_verify_callback, NULL) == 0);
  325. mbedtls_x509_crt_free(&crt);
  326. esp_crt_bundle_detach(NULL);
  327. }
  328. TEST_CASE("custom certificate bundle - wrong signature", "[mbedtls]")
  329. {
  330. /* Check that the bundle will not verify a valid certificate from trusted root where the signature is wrong */
  331. mbedtls_x509_crt crt;
  332. uint32_t flags = 0;
  333. esp_crt_bundle_attach(NULL);
  334. mbedtls_x509_crt_init( &crt );
  335. /* esp32.com cert chain where 1 byte in the signature is changed */
  336. printf("Testing certificate with wrong signature\n");
  337. mbedtls_x509_crt_parse(&crt, wrong_sig_crt_pem_start, wrong_sig_crt_pem_end - wrong_sig_crt_pem_start);
  338. TEST_ASSERT(mbedtls_x509_crt_verify(&crt, NULL, NULL, NULL, &flags, esp_crt_verify_callback, NULL) != 0);
  339. mbedtls_x509_crt_free(&crt);
  340. mbedtls_x509_crt_init( &crt );
  341. /* the correct esp32.com cert chain*/
  342. printf("Testing certificate with correct signature\n");
  343. mbedtls_x509_crt_parse(&crt, correct_sig_crt_pem_start, correct_sig_crt_pem_end - correct_sig_crt_pem_start);
  344. TEST_ASSERT(mbedtls_x509_crt_verify(&crt, NULL, NULL, NULL, &flags, esp_crt_verify_callback, NULL) == 0);
  345. mbedtls_x509_crt_free(&crt);
  346. esp_crt_bundle_detach(NULL);
  347. }
  348. TEST_CASE("custom certificate bundle init API - bound checking", "[mbedtls]")
  349. {
  350. uint8_t test_bundle[256] = {0};
  351. esp_err_t esp_ret;
  352. /* The API should fail with bundle size given as 1 */
  353. esp_ret = esp_crt_bundle_set(test_bundle, 1);
  354. TEST_ASSERT( esp_ret == ESP_ERR_INVALID_ARG);
  355. /* Check that the esp_crt_bundle_set API will not accept a bundle
  356. * which has more no. of certs than configured in
  357. * CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS */
  358. uint8_t rand;
  359. esp_fill_random(&rand, 1);
  360. test_bundle[0] = rand;
  361. /* Make sure that the number of certs will always be greater than
  362. * CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS */
  363. test_bundle[1] = rand + CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS;
  364. esp_ret = esp_crt_bundle_set(test_bundle, sizeof(test_bundle));
  365. TEST_ASSERT( esp_ret == ESP_ERR_INVALID_ARG);
  366. /* The API should fail with bundle_size < BUNDLE_HEADER_OFFSET (2) + CRT_HEADER_OFFSET (4) */
  367. test_bundle[0] = 0;
  368. test_bundle[1] = 1; /* set num_certs = 1 */
  369. esp_ret = esp_crt_bundle_set(test_bundle, 5);
  370. TEST_ASSERT(esp_ret == ESP_ERR_INVALID_ARG);
  371. /* Cert number is greater than actual certs present, The API should fail */
  372. /* Actual No. of certs present in bundle = 1, setting num_certs to 5 */
  373. test_bundle[1] = 5; /* num_certs */
  374. test_bundle[3] = 5; /* cert_1_name_len */
  375. test_bundle[5] = 10; /* cert_1_pub_key_len */
  376. /* Actual bundle size becomes BUNDLE_HEADER_OFFSET (2) + CRT_HEADER_OFFSET (4) + cert_1_name_len(5) + cert_1_pub_key_len(10)
  377. * i.e. 21 bytes */
  378. esp_ret = esp_crt_bundle_set(test_bundle, 21);
  379. TEST_ASSERT(esp_ret == ESP_ERR_INVALID_ARG);
  380. /* The API should fail if bundle_size < BUNDLE_HEADER_OFFSET (2) + CRT_HEADER_OFFSET (4) + cert_1_name_len(5) + cert_1_pub_key_len(10) */
  381. esp_ret = esp_crt_bundle_set(test_bundle, 20);
  382. TEST_ASSERT(esp_ret == ESP_ERR_INVALID_ARG);
  383. esp_crt_bundle_detach(NULL);
  384. }