Skip to content

Commit 5e78838

Browse files
authored
fix(app): explicitly use ring crypto provider (#8149)
* fix: explicitly use `ring` crypto provider * chore: add test to theseus_gui * fix: tombi
1 parent 862c64e commit 5e78838

9 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ rust-s3 = { version = "0.38.0", default-features = false, features = [
182182
"tags",
183183
"tokio-rustls-tls",
184184
] }
185-
rustls = "0.23.46"
185+
rustls = { version = "0.23.46", default-features = false }
186186
rustrict = { version = "0.7.39", default-features = false, features = ["censor"] }
187187
rusty-money = "0.5.1"
188188
same-file = "1.0.6"

‎apps/app-playground/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub async fn authenticate_run() -> theseus::Result<Credentials> {
3939
async fn main() -> theseus::Result<()> {
4040
println!("Starting.");
4141

42+
theseus::install_crypto_provider();
4243
let _log_guard = theseus::start_logger("ModrinthApp");
4344

4445
// Initialize state

‎apps/app/Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ zip = { workspace = true }
5252
workspace = true
5353
features = ["devtools", "macos-private-api", "protocol-asset"]
5454

55+
[dev-dependencies]
56+
rustls = { workspace = true, features = ["std"] }
57+
5558
[build-dependencies]
5659
tauri-build = { workspace = true, features = ["codegen"] }
5760

‎apps/app/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dev": "tauri dev --features export-app-events",
77
"lint": "cargo clippy --all-targets --features updater",
88
"lint:ancillary": "prettier --check .",
9+
"test": "cargo nextest run --all-targets --no-fail-fast --locked --features updater",
910
"fix": "cargo clippy --all-targets --features updater --fix --allow-dirty",
1011
"fix:ancillary": "prettier --write ."
1112
},

‎apps/app/src/main.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ async fn set_restart_after_pending_update(
115115
// if Tauri app is called with arguments, then those arguments will be treated as commands
116116
// ie: deep links or filepaths for .mrpacks
117117
fn main() {
118+
theseus::install_crypto_provider();
119+
118120
let runtime = tokio::runtime::Builder::new_multi_thread()
119121
.enable_all()
120122
.build()
@@ -491,3 +493,16 @@ fn main() {
491493
}
492494
}
493495
}
496+
497+
#[cfg(test)]
498+
mod tests {
499+
/// Builds a TLS config the way crates relying on rustls's process-level
500+
/// provider do (e.g. async-tungstenite for the friends socket), with the
501+
/// app's full dependency graph. This only fails here, not in app-lib's
502+
/// own tests, because a conflicting provider feature can come from
503+
/// unifying app-lib's dependencies with the Tauri plugins'.
504+
#[test]
505+
fn rustls_process_provider_is_resolvable() {
506+
let _ = rustls::ClientConfig::builder();
507+
}
508+
}

‎apps/labrinth/Cargo.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ regex = { workspace = true }
9595
reqwest = { workspace = true, features = ["http2", "json", "multipart", "rustls"] }
9696
rust_decimal = { workspace = true, features = ["serde-with-float", "serde-with-str"] }
9797
rust_iso3166 = { workspace = true }
98-
rustls.workspace = true
98+
rustls = { workspace = true, features = [
99+
"aws_lc_rs",
100+
"logging",
101+
"prefer-post-quantum",
102+
"std",
103+
"tls12",
104+
] }
99105
rustrict = { workspace = true }
100106
rusty-money = { workspace = true }
101107
scalar_api_reference = { workspace = true, features = ["actix-web"] }

‎packages/app-lib/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ reqwest = { workspace = true, features = [
7171
"http2",
7272
"json",
7373
"multipart",
74-
"rustls",
74+
"rustls-no-provider",
7575
"stream",
7676
"system-proxy",
7777
] }
7878
rgb = { workspace = true }
79+
rustls = { workspace = true, features = ["logging", "ring", "std", "tls12"] }
7980
same-file = { workspace = true }
8081
serde = { workspace = true, features = ["derive", "rc"] }
8182
serde-binhum = { workspace = true }

‎packages/app-lib/src/lib.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ pub use logger::start_logger;
3030
pub use state::State;
3131
pub use util::fetch::DownloadReason;
3232

33+
/// Installs `ring` as the process-wide rustls crypto provider.
34+
///
35+
/// Must be called before any TLS connection is made: reqwest is built with
36+
/// `rustls-no-provider` and the friends socket relies on the process default.
37+
pub fn install_crypto_provider() {
38+
let _ = rustls::crypto::ring::default_provider().install_default();
39+
}
40+
3341
pub fn launcher_user_agent() -> String {
3442
const LAUNCHER_BASE_USER_AGENT: &str =
3543
concat!("modrinth/theseus/", env!("CARGO_PKG_VERSION"),);

0 commit comments

Comments
 (0)