Skip to content

Commit

Permalink
fix(quic): correct usage of native-certs
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Sep 4, 2024
1 parent c209b0e commit b0cc53c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ os_pipe = "1.1.4"
paste = "1.0.14"
rand = "0.8.5"
rustls = { version = "0.23.1", default-features = false }
rustls-native-certs = "0.8.0"
slab = "0.4.9"
socket2 = "0.5.6"
tempfile = "3.8.1"
Expand Down
2 changes: 1 addition & 1 deletion compio-quic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ compio-runtime = { workspace = true, features = ["time"] }
quinn-proto = "0.11.3"
rustls = { workspace = true }
rustls-platform-verifier = { version = "0.3.3", optional = true }
rustls-native-certs = { version = "0.8.0", optional = true }
rustls-native-certs = { workspace = true, optional = true }
webpki-roots = { version = "0.26.3", optional = true }
h3 = { version = "0.0.6", optional = true }

Expand Down
11 changes: 10 additions & 1 deletion compio-quic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ impl ClientBuilder<rustls::RootCertStore> {
#[cfg(feature = "native-certs")]
pub fn new_with_native_certs() -> io::Result<Self> {
let mut roots = rustls::RootCertStore::empty();
roots.add_parsable_certificates(rustls_native_certs::load_native_certs()?);
let mut certs = rustls_native_certs::load_native_certs();
if certs.certs.is_empty() {
return Err(io::Error::other(
certs
.errors
.pop()
.expect("certs and errors should not be both empty"),
));
}
roots.add_parsable_certificates(certs.certs);
Ok(ClientBuilder(roots))
}

Expand Down
2 changes: 1 addition & 1 deletion compio-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compio-runtime = { workspace = true }
compio-macros = { workspace = true }

rustls = { workspace = true, default-features = false, features = ["ring"] }
rustls-native-certs = "0.8.0"
rustls-native-certs = { workspace = true }

[features]
default = ["native-tls"]
Expand Down

0 comments on commit b0cc53c

Please sign in to comment.