make pbs_tools::cert not depend on pbs-buildcfg

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-09-29 14:01:38 +02:00
parent b62edce929
commit 450105b0c3
5 changed files with 15 additions and 13 deletions

View File

@ -1,3 +1,5 @@
//! Deals with the server's current certificates (proxy.pem).
use std::path::PathBuf;
use std::mem::MaybeUninit;
@ -7,8 +9,6 @@ use openssl::x509::{X509, GeneralName};
use openssl::stack::Stack;
use openssl::pkey::{Public, PKey};
use pbs_buildcfg::configdir;
// C type:
#[allow(non_camel_case_types)]
type ASN1_TIME = <openssl::asn1::Asn1TimeRef as ForeignTypeRef>::CType;
@ -40,10 +40,6 @@ fn x509name_to_string(name: &openssl::x509::X509NameRef) -> Result<String, Error
}
impl CertInfo {
pub fn new() -> Result<Self, Error> {
Self::from_path(PathBuf::from(configdir!("/proxy.pem")))
}
pub fn from_path(path: PathBuf) -> Result<Self, Error> {
Self::from_pem(&proxmox::tools::fs::file_get_contents(&path)?)
.map_err(|err| format_err!("failed to load certificate from {:?} - {}", path, err))