@@ -99,6 +99,9 @@ pub struct SslConfiguration<'a> {
9999 pub cacert : Option < & ' a str > ,
100100 pub prvtkey : Option < & ' a str > ,
101101 pub transport_mode_secure : bool ,
102+
103+ #[ cfg( esp_idf_version_major = "5" ) ]
104+ pub use_secure_element : bool ,
102105 pub session_tickets : bool ,
103106}
104107
@@ -108,6 +111,37 @@ impl<'a> From<&SslConfiguration<'a>> for Newtype<httpd_config_t> {
108111 }
109112}
110113
114+
115+
116+
117+ #[ cfg( esp_idf_version_major = "5" ) ]
118+ impl < ' a > From < & SslConfiguration < ' a > > for CHttpsSslConfig {
119+ fn from ( conf : & SslConfiguration ) -> Self {
120+ let client_verify_cert = conf. client_verify_cert . map ( to_ptr_with_len) . unwrap_or ( ( ptr:: null_mut ( ) , 0 ) ) ;
121+ let cacert = conf. cacert . map ( to_ptr_with_len) . unwrap_or ( ( ptr:: null_mut ( ) , 0 ) ) ;
122+ let pkey = conf. prvtkey . map ( to_ptr_with_len) . unwrap_or ( ( ptr:: null_mut ( ) , 0 ) ) ;
123+
124+ Self ( httpd_ssl_config_t {
125+ httpd : httpd_config_t {
126+ ..Newtype :: < httpd_config_t > :: from ( conf) . 0
127+ } ,
128+ cacert_pem : client_verify_cert. 0 as _ ,
129+ cacert_len : client_verify_cert. 1 as _ ,
130+ servercert : cacert. 0 as _ ,
131+ servercert_len : cacert. 1 as _ ,
132+ prvtkey_pem : pkey. 0 as _ ,
133+ prvtkey_len : pkey. 1 as _ ,
134+ transport_mode : httpd_ssl_transport_mode_t_HTTPD_SSL_TRANSPORT_SECURE,
135+ use_secure_element : conf. use_secure_element ,
136+ port_secure : conf. http_configuration . https_port ,
137+ port_insecure : conf. http_configuration . http_port ,
138+ session_tickets : conf. session_tickets ,
139+ user_cb : None ,
140+ } )
141+ }
142+ }
143+
144+ #[ cfg( not( esp_idf_version_major = "5" ) ) ]
111145impl < ' a > From < & SslConfiguration < ' a > > for CHttpsSslConfig {
112146 fn from ( conf : & SslConfiguration ) -> Self {
113147 let client_verify_cert = conf. client_verify_cert . map ( to_ptr_with_len) . unwrap_or ( ( ptr:: null_mut ( ) , 0 ) ) ;
@@ -127,6 +161,7 @@ impl<'a> From<&SslConfiguration<'a>> for CHttpsSslConfig {
127161 transport_mode : httpd_ssl_transport_mode_t_HTTPD_SSL_TRANSPORT_SECURE,
128162 port_secure : conf. http_configuration . https_port ,
129163 port_insecure : conf. http_configuration . http_port ,
164+ use_secure_element : false ,
130165 session_tickets : conf. session_tickets ,
131166 user_cb : None
132167 } )
@@ -146,6 +181,7 @@ impl<'a> Default for SslConfiguration<'a> {
146181 }
147182}
148183
184+ #[ cfg( not( esp_idf_version_major = "5" ) ) ]
149185impl Drop for CHttpsSslConfig {
150186 fn drop ( & mut self ) {
151187 unsafe {
@@ -164,6 +200,26 @@ impl Drop for CHttpsSslConfig {
164200 }
165201}
166202
203+ #[ cfg( esp_idf_version_major = "5" ) ]
204+ impl Drop for CHttpsSslConfig {
205+ fn drop ( & mut self ) {
206+ unsafe {
207+ if !self . 0 . servercert . is_null ( ) {
208+ drop ( CString :: from_raw ( self . 0 . servercert as _ ) ) ;
209+ }
210+
211+ if !self . 0 . cacert_pem . is_null ( ) {
212+ drop ( CString :: from_raw ( self . 0 . cacert_pem as _ ) ) ;
213+ }
214+
215+ if !self . 0 . prvtkey_pem . is_null ( ) {
216+ drop ( CString :: from_raw ( self . 0 . prvtkey_pem as _ ) ) ;
217+ }
218+ }
219+ }
220+ }
221+
222+
167223#[ allow( non_upper_case_globals) ]
168224impl From < Newtype < c_types:: c_uint > > for Method {
169225 fn from ( method : Newtype < c_types:: c_uint > ) -> Self {
0 commit comments