[SOLVED] No Such File or Directory : x509_crt_bundle

Hello
I have been playing around with Platform IO for a bit now and have had it mostly working well. But recently I have run into an error that has me stumped. I am just using the simple example ESP IDF Hello World project in Platform IO. I used the automated feature to create the project from Home Screen. At build time, I get an initial error that states

Generating assembly for certificate bundle...
CMake Error at /Users/sriraj/.platformio/packages/framework-espidf/tools/cmake/scripts/data_file_embed_asm.cmake:26 (file):
  file failed to open for reading (No such file or directory):

    /Users/sriraj/Documents/PlatformIO/Projects/211102-232123-espidf-hello-world/.pio/build/esp32dev/x509_crt_bundle


*** Error 1

Then it proceeds to build everything else before giving a fatal error -

*** [.pio/build/esp32dev/.pio/build/esp32dev/x509_crt_bundle.o] Source .pio/build/esp32dev/x509_crt_bundle.S' not found, needed by target .pio/build/esp32dev/.pio/build/esp32dev/x509_crt_bundle.o'.

Please note the following:

  1. I got out of Platform IO - used the regular ESP IDF framework and was able to compile the same program without any issues.
  2. I ran menuconfig and disabled mbedTLS root certificate bundle and it did nothing
  3. I uninstalled and reinstalled both ESP IDF framework and Platform IO - no luck

If I create a Platform IO ESP - Arduino example project (Blink) - it compiles and runs. If I run a similar hello world program using plain vanilla ESP-IDF it works.
I am stumped! Please help… thanks in advance

Does the output also say:

Invalid certificate

If so, it’s the same issue as this one:

No - it does not state Invalid certificate. The error seems to be an absent x509_crt_bundle file in the build directory of my current project. I assume the certificate bundle is generated a build time - perhaps this is failing for some reason.

Generating assembly for certificate bundle...
CMake Error at /Users/sriraj/.platformio/packages/framework-espidf/tools/cmake/scripts/data_file_embed_asm.cmake:26 (file):
  file failed to open for reading (No such file or directory):

    /Users/sriraj/Documents/PlatformIO/Projects/211103-141542-espidf-hello-world/.pio/build/esp32-c3-devkitm-1/x509_crt_bundle

SOLVED:
The problem arises because Platform IO build process generates a x509 certificate bundle file at compile time. Further, the error thrown by the python script generating the bundle is not displayed as part of project error - all we get is that the final certificate bundle is missing.

  1. Navigate to ~/.platformio/packages/framework-espidf/components/mbedtls/esp_crt_bundle/ directory
  2. Check to ensure you have cacrt_all.pem file there, if not download root certificate bundle file from Mozilla
  3. Run python3 gen_crt_bundle.py -i cacrt_all.pem - if you get an error in this step, your root certificate bundle file is corrupt - this error is hidden during project build. Open the PEM file and delete the certificate under EC-ACC, save and re-run
  4. You should see a message like below
    gen_crt_bundle.py: Parsing certificates from cacrt_all.pem
    gen_crt_bundle.py: Successfully added 134 certificates
    gen_crt_bundle.py: Successfully added 134 certificates in total
  5. Now go and build project
1 Like

My cacrt_all.pem is fine but the it still gives the error?