]> git.proxmox.com Git - proxmox-backup.git/commitdiff
CertInfo: add is_expired_after_epoch
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 22 Apr 2021 14:01:52 +0000 (16:01 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 29 Apr 2021 09:07:04 +0000 (11:07 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/tools/cert.rs

index d3c221a4bf886483063ff231efecbc222fc2bab4..bcc3e69b3daefac0b11f73c4b1e4d6fee99308b3 100644 (file)
@@ -96,4 +96,9 @@ impl CertInfo {
     pub fn not_after_unix(&self) -> Result<i64, Error> {
         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<bool, Error> {
+        Ok(self.not_after_unix()? < epoch)
+    }
 }