2021/11/15更新:最新的esp-idf版本應該已經修復了此問題,本人嘗試了一次,直接編譯沒有問題
在使用ESP-IDF編譯工程時遇到如下報錯:
FAILED: esp-idf/mbedtls/x509_crt_bundle
cmd.exe /C "cd /D C:\Users\yahsa\Desktop\NTU\FYP\ESP_Workspace\blink\build\esp-idf\mbedtls && C:\Users\yahsa\esp.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe C:/Users/yahsa/esp/esp-idf/components/mbedtls/esp_crt_bundle/gen_crt_bundle.py --input C:/Users/yahsa/esp/esp-idf/components/mbedtls/esp_crt_bundle/cacrt_all.pem -q"
gen_crt_bundle.py: Invalid certificate in C:/Users/yahsa/esp/esp-idf/components/mbedtls/esp_crt_bundle/cacrt_all.pem
Invalid certificate
ninja: build stopped: subcommand failed.
這個問題是因為cacrt_all.pem
文件中的一個證書最近(9月30日)過期,導致編譯工程失敗。
解決辦法為,在idf.py build
編譯工程之前,輸入此命令idf.py menuconfig
進行工程配置,按照如下路徑進入Certificate Bundle
設置中,將Enable trusted root certificate bundle
選項取消掉,即不在此工程中啟用用受信任的根證書捆綁包。
(Top) > Component config > mbedTLS > Certificate Bundle->Enable trusted root certificate bundle

在VScode中使用ESP-IDF插件也是相同的辦法,打開工程后點擊左下方齒輪⚙圖標即可進行工程配置。