Skip to content

Commit

Permalink
refactor(core): fix tls features, use rustls on mobile (#6591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Mar 30, 2023
1 parent 76668b3 commit cfdee00
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changes/tls-features-automatically-enabled.md
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions .changes/tls-features-refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Renamed the `default-tls` feature to `native-tls` and added `rustls-tls` feature.
3 changes: 2 additions & 1 deletion core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion core/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down

0 comments on commit cfdee00

Please sign in to comment.