Skip to content

Commit e1d02d6

Browse files
committed
chore(oma-fetch,oma-topics): disable aws-lc-rs
1 parent 52793cc commit e1d02d6

File tree

6 files changed

+43
-134
lines changed

6 files changed

+43
-134
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ chrono = "0.4.38"
2424
rustix = { version = "1", features = ["process", "stdio"] }
2525
libc = "0.2.159"
2626
reqwest = { version = "0.13", default-features = false }
27+
rustls-platform-verifier = { version = "0.6", optional = true }
28+
rustls = { version = "0.23", default-features = false, features = ["ring", "logging", "prefer-post-quantum", "std", "tls12"], optional = true }
2729
tracing = "0.1.40"
2830
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
2931
console-subscriber = { version = "0.5.0", optional = true }
@@ -80,7 +82,7 @@ aosc = ["dep:oma-topics", "oma-refresh/aosc", "oma-pm/aosc", "oma-contents/aosc"
8082
sequoia-openssl-backend = ["oma-refresh/sequoia-openssl-backend"]
8183
sequoia-nettle-backend = ["oma-refresh/sequoia-nettle-backend"]
8284
tokio-console = ["dep:console-subscriber"]
83-
rustls = ["reqwest/default-tls", "oma-fetch/rustls", "oma-refresh/rustls", "oma-topics/rustls"]
85+
rustls = ["reqwest/rustls-no-provider", "dep:rustls-platform-verifier", "dep:rustls", "oma-fetch/rustls", "oma-refresh/rustls", "oma-topics/rustls"]
8486
openssl = ["reqwest/native-tls", "oma-fetch/native-tls", "oma-refresh/native-tls", "oma-topics/native-tls"]
8587
nice-setup = ["sequoia-nettle-backend", "rustls", "oma-refresh/apt"]
8688
openssl-setup = ["sequoia-openssl-backend", "openssl", "oma-refresh/apt"]

oma-fetch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ tokio = { version = "1.42", features = ["macros", "rt-multi-thread"] }
3131
flume = "0.12"
3232

3333
[features]
34-
rustls = ["reqwest/default-tls"]
34+
rustls = ["reqwest/rustls-no-provider"]
3535
native-tls = ["reqwest/native-tls"]
3636
default = ["rustls"]

oma-topics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ oma-console = { path = "../oma-console" }
2525
tokio = { version = "1.28", default-features = false, features = ["macros", "rt-multi-thread"] }
2626

2727
[features]
28-
rustls = ["reqwest/default-tls"]
28+
rustls = ["reqwest/rustls-no-provider"]
2929
native-tls = ["reqwest/native-tls"]
3030
default = ["rustls"]

src/main.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::{self, IsTerminal, stderr, stdin};
55
use std::path::{Path, PathBuf};
66

77
use std::process::{Command, exit};
8-
use std::sync::{LazyLock, OnceLock};
8+
use std::sync::{Arc, LazyLock, OnceLock};
99
use std::thread;
1010
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1111

@@ -37,6 +37,8 @@ use oma_utils::dbus::{create_dbus_connection, get_another_oma_status};
3737
use oma_utils::{OsRelease, is_termux};
3838
use reqwest::Client;
3939
use rustix::stdio::stdout;
40+
use rustls::ClientConfig;
41+
use rustls_platform_verifier::BuilderVerifierExt;
4042
use subcommand::utils::{LockError, is_terminal};
4143
use tokio::runtime::Runtime;
4244
use tracing::{debug, error, info, warn};
@@ -67,12 +69,15 @@ static RT: LazyLock<Runtime> = LazyLock::new(|| {
6769
.build()
6870
.expect("Failed to init async runtime")
6971
});
72+
7073
static HTTP_CLIENT: LazyLock<Client> = LazyLock::new(|| {
7174
Client::builder()
7275
.user_agent(APP_USER_AGENT)
76+
.tls_backend_preconfigured(tls_config())
7377
.build()
7478
.unwrap()
7579
});
80+
7681
static WRITER: LazyLock<Writer> = LazyLock::new(Writer::default);
7782
static LOCK: OnceLock<PathBuf> = OnceLock::new();
7883

@@ -475,6 +480,18 @@ fn try_main(
475480
code
476481
}
477482

483+
fn tls_config() -> ClientConfig {
484+
let arc_crypto_provider = Arc::new(rustls::crypto::ring::default_provider());
485+
let config = ClientConfig::builder_with_provider(arc_crypto_provider)
486+
.with_safe_default_protocol_versions()
487+
.unwrap()
488+
.with_platform_verifier()
489+
.unwrap()
490+
.with_no_client_auth();
491+
492+
config
493+
}
494+
478495
fn init_color_formatter(oma: &OhManagerAilurus, config: &Config) {
479496
let mut follow_term_color = oma.global.follow_terminal_color || config.follow_terminal_color();
480497
let no_color = oma.global.color == ColorChoice::Never;

src/subcommand/mirror.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use crate::pb::Print;
5959
use crate::subcommand::utils::multiselect;
6060
use crate::success;
6161
use crate::table::PagerPrinter;
62+
use crate::tls_config;
6263
use crate::utils::root;
6364

6465
use super::utils::Refresh;
@@ -482,10 +483,7 @@ fn set_order(
482483
fn get_latency(timeout: f64, no_progress: bool, json: bool) -> Result<i32, OutputError> {
483484
let mm = MirrorManager::new("/")?;
484485

485-
let client = blocking::ClientBuilder::new()
486-
.user_agent(APP_USER_AGENT)
487-
.timeout(Duration::from_secs_f64(timeout))
488-
.build()?;
486+
let client = client(timeout)?;
489487

490488
let mirrors = mm.mirrors_iter()?.collect::<Vec<_>>();
491489

@@ -714,10 +712,7 @@ fn speedtest(
714712
None
715713
};
716714

717-
let client = blocking::ClientBuilder::new()
718-
.user_agent(APP_USER_AGENT)
719-
.timeout(Duration::from_secs_f64(timeout))
720-
.build()?;
715+
let client = client(timeout)?;
721716

722717
let mut score_map = HashMap::with_hasher(ahash::RandomState::new());
723718

@@ -822,6 +817,16 @@ fn speedtest(
822817
Ok(0)
823818
}
824819

820+
fn client(timeout: f64) -> Result<blocking::Client, OutputError> {
821+
let client = blocking::ClientBuilder::new()
822+
.user_agent(APP_USER_AGENT)
823+
.tls_backend_preconfigured(tls_config())
824+
.timeout(Duration::from_secs_f64(timeout))
825+
.build()?;
826+
827+
Ok(client)
828+
}
829+
825830
#[inline]
826831
fn progress_bar(mirrors_len: u64) -> OmaProgressBar {
827832
OmaProgressBar::new(

0 commit comments

Comments
 (0)