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

This commit is contained in:
Lucas Fernandes Nogueira
2023-03-30 10:59:08 -03:00
committed by GitHub
parent 76668b3196
commit cfdee00f2b
5 changed files with 21 additions and 4 deletions

View File

@@ -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.

View File

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

View File

@@ -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",

View File

@@ -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.

View File

@@ -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());
}
}
}