From cfdee00f2b1455a9719bc44823fdaeabbe4c1cb2 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Thu, 30 Mar 2023 10:59:08 -0300 Subject: [PATCH] refactor(core): fix tls features, use rustls on mobile (#6591) --- .changes/tls-features-automatically-enabled.md | 6 ++++++ .changes/tls-features-refactor.md | 5 +++++ core/tauri/Cargo.toml | 3 ++- core/tauri/src/lib.rs | 3 ++- tooling/cli/src/interface/rust.rs | 8 ++++++-- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .changes/tls-features-automatically-enabled.md create mode 100644 .changes/tls-features-refactor.md diff --git a/.changes/tls-features-automatically-enabled.md b/.changes/tls-features-automatically-enabled.md new file mode 100644 index 000000000..3afa2ec3c --- /dev/null +++ b/.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. diff --git a/.changes/tls-features-refactor.md b/.changes/tls-features-refactor.md new file mode 100644 index 000000000..3b16b5c65 --- /dev/null +++ b/.changes/tls-features-refactor.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Renamed the `default-tls` feature to `native-tls` and added `rustls-tls` feature. diff --git a/core/tauri/Cargo.toml b/core/tauri/Cargo.toml index e0675ba8b..9dc82c6c9 100644 --- a/core/tauri/Cargo.toml +++ b/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", diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index 4cf6543fe..6f3260f52 100644 --- a/core/tauri/src/lib.rs +++ b/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. diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 56368e55d..30ae37fcc 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/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()); } } }