esp-rs / esp-idf-sys

Bindings for ESP-IDF (Espressif's IoT Development Framework)
Apache License 2.0
274 stars 123 forks source link

WolfSSL compile issue #226

Closed reinismu closed 1 year ago

reinismu commented 1 year ago

Want to test my firmware using WolfSSL. I added it in components

[[package.metadata.esp-idf-sys.extra_components]]
component_dirs = ["components"]

and set sdk flags

CONFIG_ESP_TLS_USING_WOLFSSL=y
CONFIG_ESP_WOLFSSL_SMALL_CERT_VEIFY=y
CONFIG_TLS_STACK_WOLFSSL=y
CONFIG_WOLFSSL_HAVE_ALPN=y

Still when I compile I get error

error[E0428]: the name `CRYPTO_LOCK` is defined multiple times
     --> /home/user/hub/target/xtensa-esp32s3-espidf/release/build/esp-idf-sys-c7bda3f590ac838e/out/bindings.rs:65585:1
      |
11964 | pub const CRYPTO_LOCK: u32 = 1;
      | ------------------------------- previous definition of the value `CRYPTO_LOCK` here
...
65585 | pub const CRYPTO_LOCK: _bindgen_ty_21 = 1;
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CRYPTO_LOCK` redefined here
      |
      = note: `CRYPTO_LOCK` must be defined only once in the value namespace of this module

error[E0428]: the name `ASN1_STRFLGS_ESC_MSB` is defined multiple times
     --> /home/user/hub/target/xtensa-esp32s3-espidf/release/build/esp-idf-sys-c7bda3f590ac838e/out/bindings.rs:65587:1
      |
12025 | pub const ASN1_STRFLGS_ESC_MSB: u32 = 4;
      | ---------------------------------------- previous definition of the value `ASN1_STRFLGS_ESC_MSB` here
...
65587 | pub const ASN1_STRFLGS_ESC_MSB: _bindgen_ty_21 = 4;
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ASN1_STRFLGS_ESC_MSB` redefined here
      |
      = note: `ASN1_STRFLGS_ESC_MSB` must be defined only once in the value namespace of this module

error[E0428]: the name `EVP_PKEY_DH` is defined multiple times
     --> /home/user/hub/target/xtensa-esp32s3-espidf/release/build/esp-idf-sys-c7bda3f590ac838e/out/bindings.rs:71460:1
      |
11874 | pub const EVP_PKEY_DH: u32 = 28;
      | -------------------------------- previous definition of the value `EVP_PKEY_DH` here
...
71460 | pub const EVP_PKEY_DH: _bindgen_ty_54 = 28;
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `EVP_PKEY_DH` redefined here
      |
      = note: `EVP_PKEY_DH` must be defined only once in the value namespace of this module

For more information about this error, try `rustc --explain E0428`.
error: could not compile `esp-idf-sys` (lib) due to 3 previous errors

Has anyone manged to get WolfSSL working with Rust?

reinismu commented 1 year ago

So it seems issue is in 2 #define. I renamed one of those to _2 and it compiled. (Very dirty)

Now I get runtime errors. Something wrong with mp_invmod

I (173601) esp_https_server: performing session handshake
E (173951) esp-tls-wolfssl: wolfSSL_accept returned -1, error code: -119
E (173951) esp_https_server: esp_tls_create_server_session failed
W (173961) httpd: httpd_accept_conn: session creation failed
W (173966) httpd: httpd_server: error accepting new connection

Will investigate further

reinismu commented 1 year ago

Changed certificate and private key to those from WolfSSL and it works now