From af100a069102b0f56521acdea31b4b6a2a7f25dd Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 24 Sep 2024 10:27:07 -0700 Subject: [PATCH] x509-cert: creates a validity to infinity (#1528) This is used for idevid certificates burned in hardware. --- x509-cert/src/time.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/x509-cert/src/time.rs b/x509-cert/src/time.rs index a3d0cfaf1..fc4fe1c48 100644 --- a/x509-cert/src/time.rs +++ b/x509-cert/src/time.rs @@ -159,6 +159,18 @@ where _profile: PhantomData, }) } + + /// Creates a `Validity` which starts now and does not expire. + #[cfg(all(feature = "std", feature = "hazmat"))] + pub fn infinity() -> der::Result { + let now = SystemTime::now(); + + Ok(Self { + not_before: Time::try_from(now)?, + not_after: Time::INFINITY, + _profile: PhantomData, + }) + } } impl<'a, P: Profile> DecodeValue<'a> for Validity

{