From c815992f984474fe02fe9d577ad11257953791f4 Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Tue, 10 Sep 2024 11:35:53 +0530 Subject: [PATCH] feat: fixed issues macos --- core/Cargo.toml | 2 +- core/src/x509/ca_cert.rs | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 8412914..7e80618 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,5 +19,5 @@ colored = "2.0" base64 = "0.21" tempfile = "3.3" -# [target.'cfg(target_os = "macos")'.dependencies] +[target.'cfg(target_os = "macos")'.dependencies] plist = "1.7.0" \ No newline at end of file diff --git a/core/src/x509/ca_cert.rs b/core/src/x509/ca_cert.rs index bb6a34c..772a385 100644 --- a/core/src/x509/ca_cert.rs +++ b/core/src/x509/ca_cert.rs @@ -12,7 +12,7 @@ use openssl::{ rsa::Rsa, x509::{extension::BasicConstraints, X509Builder, X509Name, X509}, }; -use std::io::Write; +use std::{fs, io::Write}; use std::{fs::File, io}; pub struct CACert { @@ -112,22 +112,21 @@ impl Certificate for CACert { impl CACert { pub fn load_ca_cert(cert_path: &str, key_path: &str) -> X509Result<(X509, PKey)> { - let cert: X509 = - match X509::from_pem(&std::fs::read(cert_path).map_err(|err: io::Error| { - X509Error::ErrorReadingCertFile(err, cert_path.to_string()) - })?) { - Ok(certificate) => { - println!("Reading Certificate at {} ✅", cert_path); - certificate - } - Err(err) => { - println!("Reading Certificate at {} ❌", cert_path); - return Err(X509Error::ErrorConvertingFileToData( - err, - cert_path.to_string(), - )); - } - }; + let cert: X509 = match X509::from_pem(&fs::read(cert_path).map_err(|err: io::Error| { + X509Error::ErrorReadingCertFile(err, cert_path.to_string()) + })?) { + Ok(certificate) => { + println!("Reading Certificate at {} ✅", cert_path); + certificate + } + Err(err) => { + println!("Reading Certificate at {} ❌", cert_path); + return Err(X509Error::ErrorConvertingFileToData( + err, + cert_path.to_string(), + )); + } + }; let key: PKey = match PKey::private_key_from_pem(&std::fs::read(key_path).map_err( @@ -136,7 +135,7 @@ impl CACert { Ok(key) => { println!("Reading Key at {} ✅", key_path); key - }, + } Err(err) => { println!("Reading Key at {} ❌", key_path); return Err(X509Error::ErrorConvertingFileToData(