From e495a7295d4a1267278986f01175a717cdf81047 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Thu, 12 Sep 2024 15:40:09 -0400 Subject: [PATCH] Slightly simplify certificate parsing code --- src/network.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/network.rs b/src/network.rs index f10cf268..e2346571 100644 --- a/src/network.rs +++ b/src/network.rs @@ -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. @@ -164,10 +163,7 @@ impl Network { } fn parse_ca_file(path: &str) -> Result> { - 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