Skip to content

Commit a752b95

Browse files
authored
feat: custom server cert (#625)
docs(changelog): new breaking feature fix: compability with latest esp idf sdk
1 parent de032e3 commit a752b95

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Breaking
11+
- Added custom server certificate to `http::client::Configuration`
1112
- BT: `BtDriver::set_device_name` deprecated and not available with ESP-IDF 6.0+. Use the new `EspGap::set_device_name` instead
1213
or the existing `EspBleGap::set_device_name`
1314
- Implement MQTT outbox limit and get_outbox_size()

src/http/client.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub struct Configuration {
7676
pub timeout: Option<core::time::Duration>,
7777
pub follow_redirects_policy: FollowRedirectsPolicy,
7878
pub client_certificate: Option<X509<'static>>,
79+
pub server_certificate: Option<X509<'static>>,
7980
pub private_key: Option<X509<'static>>,
8081
pub use_global_ca_store: bool,
8182
pub crt_bundle_attach: Option<unsafe extern "C" fn(conf: *mut core::ffi::c_void) -> esp_err_t>,
@@ -132,6 +133,18 @@ impl EspHttpConnection {
132133
native_config.timeout_ms = timeout.as_millis() as _;
133134
}
134135

136+
if let Some(cert) = configuration.server_certificate {
137+
#[cfg(esp_idf_version_at_least_5_5_0)]
138+
{
139+
native_config.__bindgen_anon_1.cert_pem = cert.as_esp_idf_raw_ptr() as _;
140+
}
141+
#[cfg(not(esp_idf_version_at_least_5_5_0))]
142+
{
143+
native_config.cert_pem = cert.as_esp_idf_raw_ptr() as _;
144+
}
145+
native_config.cert_len = cert.as_esp_idf_raw_len();
146+
}
147+
135148
if let (Some(cert), Some(private_key)) =
136149
(configuration.client_certificate, configuration.private_key)
137150
{

0 commit comments

Comments
 (0)