Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rustls-native-certs with rustls-platform-verifier #1734

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions quinn-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ maintenance = { status = "experimental" }
[features]
default = ["tls-rustls", "log"]
tls-rustls = ["rustls", "ring"]
# Provides `ClientConfig::with_native_roots()` convenience method
native-certs = ["rustls-native-certs"]
# Provides `ClientConfig::with_platform_verifier()` convenience method
platform-verifier = ["rustls-platform-verifier"]
# Write logs via the `log` crate when no `tracing` subscriber exists
log = ["tracing/log"]

Expand All @@ -31,7 +31,7 @@ rustc-hash = "1.1"
rand = "0.8"
ring = { version = "0.16.7", optional = true }
rustls = { version = "0.21.0", default-features = false, features = ["quic"], optional = true }
rustls-native-certs = { version = "0.6", optional = true }
rustls-platform-verifier = { version = "0.1.1", optional = true }
slab = "0.4"
thiserror = "1.0.21"
tinyvec = { version = "1.1", features = ["alloc"] }
Expand Down
28 changes: 11 additions & 17 deletions quinn-proto/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,23 +908,17 @@ impl ClientConfig {
#[cfg(feature = "rustls")]
impl ClientConfig {
/// Create a client configuration that trusts the platform's native roots
#[cfg(feature = "native-certs")]
pub fn with_native_roots() -> Self {
let mut roots = rustls::RootCertStore::empty();
match rustls_native_certs::load_native_certs() {
Ok(certs) => {
for cert in certs {
if let Err(e) = roots.add(&rustls::Certificate(cert.0)) {
tracing::warn!("failed to parse trust anchor: {}", e);
}
}
}
Err(e) => {
tracing::warn!("couldn't load any default trust roots: {}", e);
}
};

Self::with_root_certificates(roots)
#[cfg(feature = "platform-verifier")]
pub fn with_platform_verifier() -> Self {
let mut cfg = rustls::ClientConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
.with_protocol_versions(&[&rustls::version::TLS13])
.unwrap()
.with_custom_certificate_verifier(Arc::new(rustls_platform_verifier::Verifier::new()))
.with_no_client_auth();
cfg.enable_early_data = true;
Self::new(Arc::new(cfg))
}

/// Create a client configuration that trusts specified trust anchors
Expand Down
6 changes: 3 additions & 3 deletions quinn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ rust-version = "1.65"
all-features = true

[features]
default = ["native-certs", "tls-rustls", "runtime-tokio", "log"]
default = ["platform-verifier", "tls-rustls", "runtime-tokio", "log"]
# Records how long locks are held, and warns if they are held >= 1ms
lock_tracking = []
# Provides `ClientConfig::with_native_roots()` convenience method
native-certs = ["proto/native-certs"]
# Provides `ClientConfig::with_platform_verifier()` convenience method
platform-verifier = ["proto/platform-verifier"]
tls-rustls = ["rustls", "proto/tls-rustls", "ring"]
# Enables `Endpoint::client` and `Endpoint::server` conveniences
ring = ["proto/ring"]
Expand Down