Skip to content

Commit

Permalink
Import std::io directly
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Sep 4, 2024
1 parent 95c9111 commit cf0e97d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "rustls-native-certs")]
use std::io;
#[cfg(feature = "rustls-platform-verifier")]
use std::sync::Arc;

Expand Down Expand Up @@ -30,9 +32,7 @@ pub trait ConfigBuilderExt {
/// This will return an error if no valid certs were found. In that case,
/// it's recommended to use `with_webpki_roots`.
#[cfg(feature = "rustls-native-certs")]
fn with_native_roots(
self,
) -> Result<ConfigBuilder<ClientConfig, WantsClientCert>, std::io::Error>;
fn with_native_roots(self) -> Result<ConfigBuilder<ClientConfig, WantsClientCert>, io::Error>;

/// This configures the webpki roots, which are Mozilla's set of
/// trusted roots as packaged by webpki-roots.
Expand All @@ -51,9 +51,7 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {

#[cfg(feature = "rustls-native-certs")]
#[cfg_attr(not(feature = "logging"), allow(unused_variables))]
fn with_native_roots(
self,
) -> Result<ConfigBuilder<ClientConfig, WantsClientCert>, std::io::Error> {
fn with_native_roots(self) -> Result<ConfigBuilder<ClientConfig, WantsClientCert>, io::Error> {
let mut roots = rustls::RootCertStore::empty();
let mut valid_count = 0;
let mut invalid_count = 0;
Expand All @@ -64,8 +62,8 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
}

if certs.is_empty() {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
return Err(io::Error::new(
io::ErrorKind::NotFound,
format!("no native root CA certificates found (errors: {errors:?})"),
));
}
Expand All @@ -87,8 +85,8 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
);
if roots.is_empty() {
crate::log::debug!("no valid native root CA certificates found");
Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
Err(io::Error::new(
io::ErrorKind::NotFound,
format!("no valid native root CA certificates found ({invalid_count} invalid)"),
))?
}
Expand Down

0 comments on commit cf0e97d

Please sign in to comment.