Closed tirithen closed 2 months ago
Replace this line in your example:
let http_client_config = HTTPClientConfiguration::default();
with:
let http_client_config = HTTPClientConfiguration {
use_global_ca_store: true,
crt_bundle_attach: esp_idf_svc::sys::esp_crt_bundle_attach, // Not sure about this one, but I think it was necessary too
..HTTPClientConfiguration::default()
}
Then in your sdkconfig.defaults
do add:
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
... and also make sure you use a URL that starts with https://
@ivmarkov Thank you! These steps solved the TLS issue. Possibly an example like that could be added to examples/
to help anyone else trying to make HTTP calls with this crate. After all, most of the web requires TLS at this point.
I can create a pull request based on the http.rs example when in a bit.
I'll close this now, but yes - if you could contribute to the HTTP client example - even if just a few comments what needs to be set for the TLS code-path to work, that would be great!
@ivmarkov I tested again with my esp32 (using build target xtensa-esp32-espidf
) and it seems like there where no issue after adding crt_bundle_attach: Some(esp_idf_svc::sys::esp_crt_bundle_attach)
as already suggested in the example https://github.com/esp-rs/esp-idf-svc/blob/master/examples/http_client.rs#L42
I got it working also without adding the lines to the sdkconfig.defaults
file. So the example should actually be good as is. I must have missed the existing HTTPS comment before.
Thanks anyhow for the help and a good crate.
I got it working also without adding the lines to the
sdkconfig.defaults
file. So the example should actually be good as is. I must have missed the existing HTTPS comment before.
Keep in mind that the lines are added for you when compiling the examples. But... you might be right that they are not necessary, if they are y
by default (I don't remember that, but can be easily checked in the ESP IDF docu).
I'm trying to make an HTTPS/TLS GET request with this crate and I get stuck on missing TLS setup.
I get the error:
E (4482) esp-tls-mbedtls: No server verification option set in esp_tls_cfg_t structure. Check esp_tls API reference
I have a hard time finding the APIs to enable TLS, even an insecure setup. It seems like the C struct
esp_tls_cfg_t
needs to be setup, but I'm not sure how to set it up using the safe APIs. I suppose thatHTTPClientConfiguration
has something to do with it.The TLS example seem great for a raw TCP connection, but I find it hard to apply to making a HTTPS call. using
HttpClient
.This is my code so far: