From 48ff0582340b54587f40c39880992a83cb7c59f6 Mon Sep 17 00:00:00 2001 From: RisingOpsNinja <175097282+RisingOpsNinja@users.noreply.github.com.> Date: Wed, 4 Sep 2024 11:37:31 +0200 Subject: [PATCH] Log debug message with policy error description --- backend/src/utils.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/utils.rs b/backend/src/utils.rs index a2043bc..a1afe2e 100644 --- a/backend/src/utils.rs +++ b/backend/src/utils.rs @@ -30,13 +30,19 @@ use std::{ pub fn validate_cert(cert: &Cert) -> Result { 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)? + } } }