From 134ed9e14f394a3b0525e9734da9bf7d79dc0cdd Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 22 Apr 2021 16:01:52 +0200 Subject: [PATCH] CertInfo: add is_expired_after_epoch Signed-off-by: Wolfgang Bumiller --- src/tools/cert.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/cert.rs b/src/tools/cert.rs index d3c221a4..bcc3e69b 100644 --- a/src/tools/cert.rs +++ b/src/tools/cert.rs @@ -96,4 +96,9 @@ impl CertInfo { pub fn not_after_unix(&self) -> Result { asn1_time_to_unix(&self.not_after()) } + + /// Check if the certificate is expired at or after a specific unix epoch. + pub fn is_expired_after_epoch(&self, epoch: i64) -> Result { + Ok(self.not_after_unix()? < epoch) + } } -- 2.39.2