Просмотр исходного кода

refactor(core): fix tls features, use rustls on mobile (#6591)

Lucas Fernandes Nogueira 2 лет назад
Родитель
Сommit
cfdee00f2b

+ 6 - 0
.changes/tls-features-automatically-enabled.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Automatically enable the `rustls-tls` tauri feature on mobile and `native-tls` on desktop if `rustls-tls` is not enabled.

+ 5 - 0
.changes/tls-features-refactor.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Renamed the `default-tls` feature to `native-tls` and added `rustls-tls` feature.

+ 2 - 1
core/tauri/Cargo.toml

@@ -155,8 +155,9 @@ http-api = [ ]
 http-multipart = [ "reqwest/multipart" ]
 shell-open-api = [ "open", "regex", "tauri-macros/shell-scope" ]
 fs-extract-api = [ "zip" ]
-default-tls = [ "reqwest/default-tls" ]
+native-tls = [ "reqwest/native-tls" ]
 native-tls-vendored = [ "reqwest/native-tls-vendored" ]
+rustls-tls = [ "reqwest/rustls-tls" ]
 process-command-api = [ "shared_child", "os_pipe" ]
 global-shortcut = [
   "tauri-runtime/global-shortcut",

+ 2 - 1
core/tauri/src/lib.rs

@@ -22,8 +22,9 @@
 //! - **shell-open-api**: Enables the [`api::shell`] module.
 //! - **http-api**: Enables the [`api::http`] module.
 //! - **http-multipart**: Adds support to `multipart/form-data` requests.
-//! - **default-tls**: Provides TLS support to connect over HTTPS.
+//! - **native-tls**: Provides TLS support to connect over HTTPS.
 //! - **native-tls-vendored**: Compile and statically link to a vendored copy of OpenSSL.
+//! - **rustls-tls**: Provides TLS support to connect over HTTPS using rustls.
 //! - **process-command-api**: Enables the [`api::process::Command`] APIs.
 //! - **global-shortcut**: Enables the global shortcut APIs.
 //! - **clipboard**: Enables the clipboard APIs.

+ 6 - 2
tooling/cli/src/interface/rust.rs

@@ -350,13 +350,17 @@ fn shared_options(
   app_settings: &RustAppSettings,
 ) {
   if mobile {
+    features
+      .get_or_insert(Vec::new())
+      .push("tauri/rustls-tls".into());
+  } else {
     let all_features = app_settings
       .manifest
       .all_enabled_features(if let Some(f) = features { f } else { &[] });
-    if all_features.contains(&"tauri/default-tls".into()) {
+    if !all_features.contains(&"tauri/rustls-tls".into()) {
       features
         .get_or_insert(Vec::new())
-        .push("tauri/native-tls-vendored".into());
+        .push("tauri/native-tls".into());
     }
   }
 }