Skip to content

Commit

Permalink
Slightly simplify certificate parsing code
Browse files Browse the repository at this point in the history
  • Loading branch information
mystor committed Sep 12, 2024
1 parent 27cb4ca commit e495a72
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::{
errors::{DownloadError, SourceFile},
PartialConfig,
};
use std::io::Read;

/// Wrapper for the pair of a `reqwest::Response` and the `SemaphorePermit` used
/// to limit concurrent connections, with a test-only variant for mocking.
Expand Down Expand Up @@ -164,10 +163,7 @@ impl Network {
}

fn parse_ca_file(path: &str) -> Result<reqwest::Certificate, Box<dyn std::error::Error>> {
let mut buf = Vec::new();
std::fs::File::open(path)?.read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_pem(&buf)?;
Ok(cert)
Ok(reqwest::Certificate::from_pem(&std::fs::read(path)?)?)
}

/// Download a file and persist it to disk
Expand Down

0 comments on commit e495a72

Please sign in to comment.