0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-12-05 03:12:50 +01:00

Log debug message with policy error description

This commit is contained in:
RisingOpsNinja 2024-09-04 11:37:31 +02:00
parent f046cd0fca
commit 48ff058234

View file

@ -30,13 +30,19 @@ use std::{
pub fn validate_cert(cert: &Cert) -> Result<ValidCert> {
let validcert = match log_err!(cert.with_policy(&*POLICY, None), debug) {
Ok(validcert) => validcert,
Err(_) => Err(SpecialErrors::InvalidCert)?,
Err(e) => {
debug!("Certificate was rejected: The primary key violates the policy: {}", e.source().unwrap());
Err(SpecialErrors::InvalidCert)?
}
};
for key in cert.keys().subkeys() {
match log_err!(key.with_policy(&*POLICY, None), debug) {
Ok(_) => continue,
Err(_) => Err(SpecialErrors::KeyPolicyViolation)?,
Err(e) => {
debug!("Certificate was rejected: A sub key violates the policy: {}", e.source().unwrap());
Err(SpecialErrors::KeyPolicyViolation)?
}
}
}