common: adapt to changes in proxmox_subscription

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-07-21 13:33:47 +02:00
parent 95e5e59fd0
commit 31a1c78845

View File

@ -70,17 +70,16 @@ mod export {
use anyhow::{bail, format_err, Error}; use anyhow::{bail, format_err, Error};
use proxmox_subscription::SubscriptionInfo; use proxmox_subscription::SubscriptionInfo;
use proxmox_sys::fs::{file_get_contents, CreateOptions}; use proxmox_sys::fs::CreateOptions;
use super::client::UreqClient; use super::client::UreqClient;
#[export] #[export]
fn read_subscription(path: String) -> Result<Option<SubscriptionInfo>, Error> { fn read_subscription(path: String) -> Result<Option<SubscriptionInfo>, Error> {
let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; proxmox_subscription::files::read_subscription(
let key = openssl::pkey::PKey::public_key_from_pem(&key) path.as_str(),
.map_err(|err| format_err!("Failed to parse public key - {err}"))?; &[proxmox_subscription::files::DEFAULT_SIGNING_KEY],
)
proxmox_subscription::files::read_subscription(path, &key)
} }
#[export] #[export]
@ -154,11 +153,7 @@ mod export {
bail!("SubscriptionInfo is not signed!"); bail!("SubscriptionInfo is not signed!");
} }
let key = file_get_contents("/usr/share/keyrings/proxmox-offline-signing-key.pub")?; info.check_signature(&[proxmox_subscription::files::DEFAULT_SIGNING_KEY]);
let key = openssl::pkey::PKey::public_key_from_pem(&key)
.map_err(|err| format_err!("Failed to parse public key - {err}"))?;
info.check_signature(&key);
Ok(info) Ok(info)
} }