Use system certs when using openssl

This commit is contained in:
bytedream 2023-08-25 17:15:06 +02:00
parent 3ae6fe4a1a
commit 18f891efd2
3 changed files with 77 additions and 11 deletions

View file

@ -6,15 +6,15 @@ edition = "2021"
license = "MIT"
[features]
openssl = ["reqwest/native-tls-alpn"]
openssl-static = ["reqwest/native-tls-alpn", "reqwest/native-tls-vendored"]
openssl = ["reqwest/native-tls-alpn", "dep:rustls-native-certs"]
openssl-static = ["reqwest/native-tls-alpn", "reqwest/native-tls-vendored", "dep:rustls-native-certs"]
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
clap = { version = "4.3", features = ["derive", "string"] }
chrono = "0.4"
crunchyroll-rs = { version = "0.6.1", features = ["dash-stream"] }
crunchyroll-rs = { version = "0.6.2", features = ["dash-stream"] }
ctrlc = "3.4"
dialoguer = { version = "0.10", default-features = false }
dirs = "5.0"
@ -31,9 +31,10 @@ serde = "1.0"
serde_json = "1.0"
serde_plain = "1.0"
shlex = "1.1"
sys-locale = "0.3"
tempfile = "3.7"
tokio = { version = "1.31", features = ["macros", "rt-multi-thread", "time"] }
sys-locale = "0.3"
rustls-native-certs = { version = "0.6", optional = true }
[build-dependencies]
chrono = "0.4"

View file

@ -271,7 +271,17 @@ async fn crunchyroll_session(cli: &mut Cli) -> Result<Crunchyroll> {
CrunchyrollBuilder::predefined_client_builder()
};
#[cfg(any(feature = "openssl", feature = "openssl-static"))]
let client = builder.use_native_tls().build().unwrap();
let client = {
let mut builder = builder.use_native_tls().tls_built_in_root_certs(false);
for certificate in rustls_native_certs::load_native_certs().unwrap() {
builder = builder.add_root_certificate(
reqwest::Certificate::from_der(certificate.0.as_slice()).unwrap(),
)
}
builder.build().unwrap()
};
#[cfg(not(any(feature = "openssl", feature = "openssl-static")))]
let client = builder.build().unwrap();