Skip to content

echo_server example fails to build for ESP32 due to redefinition of certs #826

Closed

Description

@fastjack

I tried to build the echo_server example as described on the WolfSSL page at https://www.wolfssl.com/wolfssh-now-available-as-an-espressif-managed-component-includes-ssh-echo-server-example/

I'm using ESP-IDF 5.5 on macOS. I created the example project with: idf.py create-project-from-example "wolfssl/wolfssh:wolfssh_echoserver". Configured Wifi credentials with menuconfig and then tried to build the project with idf.py build.

But the project failed to build with the following messages:

In file included from /Users/fastjack/Developer/IoT/wolfssh_echoserver/main/echoserver.c:65:
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssh/wolfssh/certs_test.h:27:28: error: redefinition of 'rsa_key_der_2048'
   27 | static const unsigned char rsa_key_der_2048[] =
      |                            ^~~~~~~~~~~~~~~~
In file included from /Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/include/user_settings.h:1062,
                 from /Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/wolfssl/wolfcrypt/settings.h:340,
                 from /Users/fastjack/Developer/IoT/wolfssh_echoserver/main/echoserver.c:29:
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/wolfssl/certs_test.h:1384:28: note: previous definition of 'rsa_key_der_2048' with type 'const unsigned char[1191]'
 1384 | static const unsigned char rsa_key_der_2048[] =
      |                            ^~~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssh/wolfssh/certs_test.h:150:18: error: redefinition of 'sizeof_rsa_key_der_2048'
  150 | static const int sizeof_rsa_key_der_2048 = sizeof(rsa_key_der_2048);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/wolfssl/certs_test.h:1507:18: note: previous definition of 'sizeof_rsa_key_der_2048' with type 'int'
 1507 | static const int sizeof_rsa_key_der_2048 = sizeof(rsa_key_der_2048);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssh/wolfssh/certs_test.h:153:28: error: redefinition of 'ecc_key_der_256'
  153 | static const unsigned char ecc_key_der_256[] =
      |                            ^~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/wolfssl/certs_test.h:6187:28: note: previous definition of 'ecc_key_der_256' with type 'const unsigned char[121]'
 6187 | static const unsigned char ecc_key_der_256[] =
      |                            ^~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssh/wolfssh/certs_test.h:169:18: error: redefinition of 'sizeof_ecc_key_der_256'
  169 | static const int sizeof_ecc_key_der_256 = sizeof(ecc_key_der_256);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
/Users/fastjack/Developer/IoT/wolfssh_echoserver/managed_components/wolfssl__wolfssl/wolfssl/certs_test.h:6203:18: note: previous definition of 'sizeof_ecc_key_der_256' with type 'int'
 6203 | static const int sizeof_ecc_key_der_256 = sizeof(ecc_key_der_256);
      |                  ^~~~~~~~~~~~~~~~~~~~~~

Steps to reproduce:

  1. Set up ESP-IDF paths with source ~/esp/v5.5/esp-idf/export.sh
  2. idf.py create-project-from-example "wolfssl/wolfssh:wolfssh_echoserver"
  3. Enter project directory and build with idf.py build

Activity

  1. embhorn commented on Aug 21, 2025

    @embhorn
    Member

    Hello @fastjack ,

    Thanks for contacting wolfSSL Support. I have requested a review of this issue by our engineers. Could you tell us a bit about your ESP32 project using wolfSSL?

    Thanks,
    @embhorn - wolfSSL Support

  2. gojimmypi commented on Aug 21, 2025

    @gojimmypi
    Contributor

    Hi @fastjack and @embhorn

    I've confirmed this is problematic with multiple versions of the ESP-IDF. I tested on latest master ESP-IDF v6.0

    The root cause appears to be specific the the most recent v5.8.2 Managed Component release of wolfSSL which was not tested against the prior published wolfSSH examples.

    Specifically, the same-name certs_test.h file is included in both wolfSSL and wolfSSH components,

    ... but gated with #define WOLFSSL_CERTS_TEST_H (SSL) and #define _WOLFSSH_CERTS_TEST_H_ (SSH), respectfully.

    As an interim fix until I resolve this, one can set an explicit version of wolfSSL in the wolfssh_echoserver/main/idf_component.yml:

    dependencies:
      idf:
        version: '>=4.1.0'
      wolfssl/wolfssh:
        version: ^1.4.20
      wolfssl/wolfssl:
        version: 5.8.0

    Note the last line was changed from the default:

        version: ^5.7.6
    

    to

        version: 5.8.0
    

    ... to use the prior release from current wolfssl v5.8.2. Be sure to OMIT the "greater than version" carat: ^ char.

    Be sure to fully clean the prior build from the wolfssh_echoserver directory:

    rm -rf ./build
    rm ./dependencies.lock

    See also: wolfSSL/wolfssl#9099 that changed sizeof definitions to macros after the v5.8.2 release.

  3. gojimmypi commented on Aug 21, 2025

    @gojimmypi
    Contributor

    Update: the root cause of this problem is from wolfSSL/wolfssl#8813, specifically line 1084 of the template example user_settings.h.

    The reminder in comments to #include <wolfssl/certs_test.h> was uncommented, thus causing conflicts between the certs_test.h in wolfSSL and the same-name file in wolfSSH.

    An alternative solution to this problem would be to simply edit the respective user settings file in:

    wolfssh_echoserver/managed_components/wolfssl__wolfssl/include/user_settings.h
    

    and comment out the #include <wolfssl/certs_test.h> line.

    Of course, in doing so, one would also need to then convert the entire component to a non-managed one as prompted.

    $ idf.py fullclean
    Executing action: fullclean
    Executing action: remove_managed_components
    ERROR: Some components in the "managed_components" directory were modified on the disk since the last run of the CMake.
    
    wolfssl__wolfssl: Hash of the file "include/user_settings.h" in the component in "/mnt/c/test/wolfssh_echoserver.bak/managed_components/wolfssl__wolfssl" does not match expected hash "8ac1b765e20c9034f36bef312cb7a97589b6fb4d2582f7be68d52662498a171a"
    
    Content of this directory is managed automatically.
    If you want to keep the changes, you can move the directory with the component to the "components" folder of your project.
    I.E. for "wolfssl__wolfssl" run:
    mv /mnt/c/test/wolfssh_echoserver.bak/managed_components/wolfssl__wolfssl /mnt/c/test/wolfssh_echoserver.bak/components/wolfssl__wolfssl
    If you want to discard the changes, remove the whole component directory from the "managed_components".
    

    A post-release wolfSSL Managed Component will be needed - as once published, version numbers cannot be reused.

  4. gojimmypi commented on Aug 24, 2025

    @gojimmypi
    Contributor

    Hi @fastjack -

    I've published a minor revision 5.8.2~1 of wolfssl in the ESP Registry that uses the current minor change in wolfSSL/wolfssl#9123 to comment out the #include <wolfssl/certs_test.h>.

    No other changes were made to wolfSSL core library. This is still based on the 5.8.2 release; none of the other post release changes were added.

    I've confirmed the wolfSSH idf.py create-project-from-example "wolfssl/wolfssh=1.4.20:wolfssh_echoserver" now works properly, albeit with a few warnings in ESP-IDF v6.0 about newly deprecated SNTP functions.

  5. fastjack commented on Aug 24, 2025

    @fastjack
    Author

    I was able to create a new project and build it successfully. The example works as advertised. Thank you!

  6. gojimmypi commented on Aug 24, 2025

    @gojimmypi
    Contributor

    Hi @fastjack - thanks for confirming the update works for you.

    If you are interested in another wolfSSH example for Espressif devices, check out the SSH to UART example:

    https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif/ESP32/ESP32-SSH-Server

    Let me know if there's anything I can do to help you with your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions