esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

[HTTP Stream] http_stream_cfg_t.crt_bundle_attach 无效,无法通过CA证书验证 (AUD-6311)

Open Old-Liu opened this issue 8 months ago • 2 comments

Before submitting a new issue, please follow the checklist and try to find the answer.

  • [ √] I have read the documentation Espressif Advanced Development Framework Guide and the issue is not addressed there.
  • [ √] I have updated my ADF and IDF branch (master or release) to the latest version and checked that the issue is present there.
  • [ √] I have searched the issue tracker for a similar issue and not found a similar issue.

Environment

  • Audio development kit: ESP32-S3-Korvo-2
  • Audio kit version (ESP32-S3-Korvo-2): [v1|v2|v3|v4]
  • [Required] Module or chip used: [ESP32-S3-WROOM-1]
  • [Required] IDF version (run git describe --tags in $IDF_PATH folder to find it): v5.4.1
  • [Required] ADF version (run git describe --tags in $ADF_PATH folder to find it): v2.7-69-g0d766501
  • Build system: [Make|CMake|idf.py]
  • [Required] Running log: All logs from power-on to problem recurrence
  • Compiler version (run xtensa-esp32-elf-gcc --version in your project folder to find it): // 1.22.0-80-g6c4433a
  • Operating system: [Windows|Linux|macOS]
  • (Windows only) Environment type: [MSYS2 mingw32|ESP Command Prompt|Plain Command Prompt|PowerShell]
  • Using an IDE?: [No|Yes (please give details)]
  • Power supply: [USB|external 5V|external 3.3V|Battery]

Problem Description

我参考了pipeline_baidu_speech_mp3例程,不过我添加了证书验证的选项: http_stream_cfg_t http_cfg = HTTP_STREAM_CFG_DEFAULT(); http_cfg.event_handle = _http_stream_event_handle; http_cfg.type = AUDIO_STREAM_READER; http_cfg.crt_bundle_attach = esp_crt_bundle_attach; // http_cfg.cert_pem = (const char *)x509_crt_imported_bundle_bin_start; audio_element_handle_t http_stream_reader = http_stream_init(&http_cfg); audio_element_set_uri(http_stream_reader, BAIDU_TTS_ENDPOINT);

我还尝试了检查此函数是否被调用 esp_err_t my_crt_bundle_attach(void *conf) { ESP_LOGI(TAG, "测试是否调用"); return esp_crt_bundle_attach(conf); } http_cfg.crt_bundle_attach = my_crt_bundle_attach; 结果日志中也没出现"测试是否调用",我想知道ADF的http_stream底层是否支持CA证书校验,因为官方的例子是勾选了跳过验证

但是我认为他没能正确运行,日志如下: I (40215) SNTP: Current Time: 2025-04-30 00:17:29 I (40215) MP3_DECODER: MP3 init I (40215) AUDIO_PIPELINE: link el->rb, el:0x3c197194, tag:http, rb:0x3c197960 I (40215) AUDIO_PIPELINE: link el->rb, el:0x3c1977f0, tag:mp3, rb:0x3c19c9a8 I (40225) AUDIO_THREAD: The http task allocate stack on external memory I (40225) AUDIO_ELEMENT: [http-0x3c197194] Element task created I (40235) AUDIO_THREAD: The mp3 task allocate stack on external memory I (40235) AUDIO_ELEMENT: [mp3-0x3c1977f0] Element task created I (40245) AUDIO_THREAD: The i2s task allocate stack on internal memory I (40255) AUDIO_ELEMENT: [i2s-0x3c197478] Element task created I (40255) AUDIO_PIPELINE: Func:audio_pipeline_run, Line:359, MEM Total:8231140 Bytes, Inter:144047 Bytes, Dram:144047 Bytes, Dram largest free:47104Bytes

I (40275) AUDIO_ELEMENT: [http] AEL_MSG_CMD_RESUME,state:1 I (40275) AUDIO_ELEMENT: [mp3] AEL_MSG_CMD_RESUME,state:1 I (40285) MP3_DECODER: MP3 opened I (40285) AUDIO_ELEMENT: [i2s] AEL_MSG_CMD_RESUME,state:1 I (40295) AUDIO_PIPELINE: Pipeline started E (40325) esp-tls-mbedtls: No server verification option set in esp_tls_cfg_t structure. Check esp_tls API reference E (40325) esp-tls-mbedtls: Failed to set client configurations, returned [0x8017] (ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) E (40335) esp-tls: create_ssl_handle failed E (40335) esp-tls: Failed to open new connection E (40335) transport_base: Failed to open a new connection E (40345) HTTP_CLIENT: Connection failed, sock < 0 E (40345) BAIDU_AUTH: Error open http request to baidu auth server E (40355) MAIN: Error issuing access token E (40355) HTTP_STREAM: Failed to process user callback E (40365) AUDIO_ELEMENT: [http] AEL_STATUS_ERROR_OPEN,-1 W (40365) AUDIO_ELEMENT: [http] audio_element_on_cmd_error,7 W (40375) AUDIO_ELEMENT: IN-[mp3] AEL_IO_ABORT E (40375) MP3_DECODER: Failed to read audio data (line 136) W (40385) AUDIO_ELEMENT: [mp3] AEL_IO_ABORT, -3 I (40385) MP3_DECODER: Closed I (40395) AUDIO_ELEMENT: [i2s] AEL_MSG_CMD_PAUSE I (40395) AUDIO_ELEMENT: [i2s] AEL_MSG_CMD_RESUME,state:4 W (40405) AUDIO_ELEMENT: IN-[i2s] AEL_IO_ABORT W (40405) MAIN: [ * ] Stop event received W (40405) AUDIO_ELEMENT: [http] Element already stopped W (40415) AUDIO_ELEMENT: [mp3] Element already stopped W (40415) AUDIO_ELEMENT: [i2s] Element already stopped I (40425) main_task: Returned from app_main() // Detailed problem description goes here.

Old-Liu avatar Apr 29 '25 16:04 Old-Liu

#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1

/** Major version number (X.x.x) / #define ESP_IDF_VERSION_MAJOR 5 /* Minor version number (x.X.x) / #define ESP_IDF_VERSION_MINOR 4 /* Patch version number (x.x.X) */ #define ESP_IDF_VERSION_PATCH 1

相关的配置已使能

Old-Liu avatar Apr 29 '25 16:04 Old-Liu

可以直接sdkconfig 看一下

shootao avatar May 16 '25 04:05 shootao