Skip to content

Commit 27096cd

Browse files
authored
fix(cli): don't force native-tls feature on desktop (#12445)
1 parent 6cbfc48 commit 27096cd

File tree

5 files changed

+36
-44
lines changed

5 files changed

+36
-44
lines changed

.changes/cli-core-native-tls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
tauri-cli: patch:bug
3+
tauri: patch:bug
4+
---
5+
6+
Fixed an issue that caused Tauri's CLI to enable tauri's `native-tls` feature even though it wasn't needed. Moved `reqwest` to a mobile-only dependency in `tauri` and enabled its `rustls-tls` feature flag.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/tauri-cli/src/interface/rust.rs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -360,35 +360,6 @@ fn lookup<F: FnMut(FileType, PathBuf)>(dir: &Path, mut f: F) {
360360
}
361361
}
362362

363-
fn shared_options(
364-
desktop_dev: bool,
365-
mobile: bool,
366-
args: &mut Vec<String>,
367-
features: &mut Option<Vec<String>>,
368-
app_settings: &RustAppSettings,
369-
) {
370-
if mobile {
371-
args.push("--lib".into());
372-
features
373-
.get_or_insert(Vec::new())
374-
.push("tauri/rustls-tls".into());
375-
} else {
376-
if !desktop_dev {
377-
args.push("--bins".into());
378-
}
379-
let all_features = app_settings
380-
.manifest
381-
.lock()
382-
.unwrap()
383-
.all_enabled_features(if let Some(f) = features { f } else { &[] });
384-
if !all_features.contains(&"tauri/rustls-tls".into()) {
385-
features
386-
.get_or_insert(Vec::new())
387-
.push("tauri/native-tls".into());
388-
}
389-
}
390-
}
391-
392363
fn dev_options(
393364
mobile: bool,
394365
args: &mut Vec<String>,
@@ -409,7 +380,11 @@ fn dev_options(
409380
}
410381
*args = dev_args;
411382

412-
shared_options(true, mobile, args, features, app_settings);
383+
if mobile {
384+
args.push("--lib".into());
385+
} else {
386+
args.push("--bins".into());
387+
}
413388

414389
if !args.contains(&"--no-default-features".into()) {
415390
let manifest_features = app_settings.manifest.lock().unwrap().features();
@@ -489,7 +464,9 @@ impl Rust {
489464
features
490465
.get_or_insert(Vec::new())
491466
.push("tauri/custom-protocol".into());
492-
shared_options(false, mobile, args, features, &self.app_settings);
467+
if mobile {
468+
args.push("--lib".into());
469+
}
493470
}
494471

495472
fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(

crates/tauri/Cargo.toml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ serde_repr = "0.1"
6868
http = "1"
6969
dirs = "6"
7070
percent-encoding = "2"
71-
reqwest = { version = "0.12", default-features = false, features = [
72-
"json",
73-
"stream",
74-
] }
75-
bytes = { version = "1", features = ["serde"] }
7671
raw-window-handle = { version = "0.6", features = ["std"] }
7772
glob = "0.3"
7873
urlpattern = "0.3"
@@ -89,13 +84,16 @@ specta = { version = "^2.0.0-rc.16", optional = true, default-features = false,
8984
"function",
9085
"derive",
9186
] }
92-
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
87+
88+
# desktop
89+
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "windows", target_os = "macos"))'.dependencies]
9390
muda = { version = "0.15", default-features = false, features = ["serde"] }
9491
tray-icon = { version = "0.19", default-features = false, features = [
9592
"serde",
9693
], optional = true }
9794

98-
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
95+
# linux
96+
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies]
9997
gtk = { version = "0.18", features = ["v3_24"] }
10098
webkit2gtk = { version = "=2.0.1", features = ["v2_40"] }
10199

@@ -120,15 +118,23 @@ objc2-app-kit = { version = "0.2", default-features = false, features = [
120118
] }
121119
window-vibrancy = "0.5"
122120

121+
# windows
123122
[target."cfg(windows)".dependencies]
124123
webview2-com = "0.34"
125124
window-vibrancy = "0.5"
125+
windows = { version = "0.58", features = ["Win32_Foundation"] }
126126

127-
[target."cfg(windows)".dependencies.windows]
128-
version = "0.58"
129-
features = ["Win32_Foundation"]
127+
# mobile
128+
[target.'cfg(any(target_os = "android", all(target_vendor = "apple", not(target_os = "macos"))))'.dependencies]
129+
bytes = { version = "1", features = ["serde"] }
130+
reqwest = { version = "0.12", default-features = false, features = [
131+
"json",
132+
"stream",
133+
"rustls-tls",
134+
] }
130135

131-
[target."cfg(target_os = \"android\")".dependencies]
136+
# android
137+
[target.'cfg(target_os = "android")'.dependencies]
132138
jni = "0.21"
133139

134140
# UIKit, i.e. iOS/tvOS/watchOS/visionOS
@@ -179,9 +185,11 @@ objc-exception = ["tauri-runtime-wry/objc-exception"]
179185
linux-libxdo = ["tray-icon/libxdo", "muda/libxdo"]
180186
isolation = ["tauri-utils/isolation", "tauri-macros/isolation", "uuid"]
181187
custom-protocol = ["tauri-macros/custom-protocol"]
188+
# TODO: Remove these flags in v3 and/or enable them by default behind a mobile flag https://github.com/tauri-apps/tauri/issues/12384
189+
# For now those feature flags keep enabling reqwest features in case some users depend on that by accident.
182190
native-tls = ["reqwest/native-tls"]
183191
native-tls-vendored = ["reqwest/native-tls-vendored"]
184-
rustls-tls = ["reqwest/rustls-tls"]
192+
rustls-tls = []
185193
devtools = ["tauri-runtime/devtools", "tauri-runtime-wry/devtools"]
186194
process-relaunch-dangerous-allow-symlink-macos = [
187195
"tauri-utils/process-relaunch-dangerous-allow-symlink-macos",

crates/tauri/src/protocol/tauri.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ fn get_response<R: Runtime>(
115115
);
116116

117117
let mut proxy_builder = reqwest::ClientBuilder::new()
118+
.use_rustls_tls()
118119
.build()
119120
.unwrap()
120121
.request(request.method().clone(), &url);

0 commit comments

Comments
 (0)