From d62c546ce1f7c2b3211e5ced4ccd4be0ae0fc07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A6Ltorio?= Date: Mon, 16 Dec 2024 17:55:56 +0100 Subject: [PATCH] bug --- src/api/mod.rs | 29 ++++++++++++++++++++++++----- src/main.rs | 4 +++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index 8f24358..ef701cf 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -11,7 +11,7 @@ use handlers::DataHandler; use handlers::DownloadHandler; use handlers::UploadHandler; use indicatif::{ProgressBar, ProgressStyle}; -use crate::ca_bundle::get_cert_bundle; +use crate::ca_bundle::CERT_BUNDLE; use log; @@ -36,8 +36,8 @@ fn new_easy2_data( let _ = easy2.ssl_verify_host(false); let _ = easy2.ssl_verify_peer(false); } else { - if env::var("CURL_USE_SYSTEM_CA_BUNDLE") == Ok("1".to_string()) { - if easy2.ssl_cainfo_blob(get_cert_bundle().as_bytes()) != Ok(()) { + if env::var("CURL_USE_INTERNAL_CA_BUNDLE") == Ok("1".to_string()) { + if easy2.ssl_cainfo_blob(CERT_BUNDLE) != Ok(()) { log::error!("Failed to load cacert.pem"); } } @@ -90,6 +90,12 @@ pub fn new_easy2_download( if env::var("CURL_VERBOSE") == Ok("1".to_string()) { let _ = easy2.verbose(true); } + + if env::var("CURL_USE_INTERNAL_CA_BUNDLE") == Ok("1".to_string()) { + if easy2.ssl_cainfo_blob(CERT_BUNDLE) != Ok(()) { + log::error!("Failed to load cacert.pem"); + } + } let mut merged_headers: Vec = DEFAULT_HEADERS.iter().map(|x| x.to_string()).collect(); @@ -153,8 +159,8 @@ pub fn new_easy2_upload( let _ = easy2.ssl_verify_host(false); let _ = easy2.ssl_verify_peer(false); } else { - if env::var("CURL_USE_SYSTEM_CA_BUNDLE") == Ok("1".to_string()) { - if easy2.ssl_cainfo_blob(get_cert_bundle().as_bytes()) != Ok(()) { + if env::var("CURL_USE_INTERNAL_CA_BUNDLE") == Ok("1".to_string()) { + if easy2.ssl_cainfo_blob(&CERT_BUNDLE) != Ok(()) { log::error!("Failed to load cacert.pem"); } } @@ -177,6 +183,12 @@ pub fn get(url: &str, additional_headers: Option>) -> Result Result<(), SwishError> { let system_ca_bundle = cli.system_ca_bundle; // Set the system CA bundle flag as an environment variable if system_ca_bundle { - env::set_var("CURL_USE_SYSTEM_CA_BUNDLE", "1"); + env::set_var("CURL_USE_INTERNAL_CA_BUNDLE", "0"); + } else { + env::set_var("CURL_USE_INTERNAL_CA_BUNDLE", "1"); } //check if the arg is a link