Skip to content

Commit

Permalink
feat: fixed issues macos
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhexists committed Sep 10, 2024
1 parent 6f335fc commit c815992
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
35 changes: 17 additions & 18 deletions core/src/x509/ca_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -112,22 +112,21 @@ impl Certificate for CACert {

impl CACert {
pub fn load_ca_cert(cert_path: &str, key_path: &str) -> X509Result<(X509, PKey<Private>)> {
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<Private> =
match PKey::private_key_from_pem(&std::fs::read(key_path).map_err(
Expand All @@ -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(
Expand Down

0 comments on commit c815992

Please sign in to comment.