diff --git a/src/commons/api/ca.rs b/src/commons/api/ca.rs index cc4d7924..094a1ed4 100644 --- a/src/commons/api/ca.rs +++ b/src/commons/api/ca.rs @@ -335,6 +335,18 @@ impl IssuedCert { pub fn replaces(&self) -> Option<&ReplacedObject> { self.replaces.as_ref() } + + /// Returns a (possibly empty) set of reduced applicable resources which is the intersection + /// of the encompassing resources and this certificate's current resources. + /// Returns None if the current resource set is not overclaiming and does not need to be + /// reduced. + pub fn reduced_applicable_resources(&self, encompassing: &ResourceSet) -> Option { + if encompassing.contains(&self.resource_set) { + None + } else { + Some(encompassing.intersection(&self.resource_set)) + } + } } impl PartialEq for IssuedCert { diff --git a/src/daemon/ca/aspa.rs b/src/daemon/ca/aspa.rs index af7cd93c..70d671f1 100644 --- a/src/daemon/ca/aspa.rs +++ b/src/daemon/ca/aspa.rs @@ -8,7 +8,6 @@ use std::{collections::HashMap, fmt::Debug}; -use chrono::Duration; use rpki::repository::{ aspa::{Aspa, AspaBuilder}, sigobj::SignedObjectBuilder, @@ -190,19 +189,24 @@ impl AspaObjects { Ok(object_updates) } - // Re-new ASPAs before they would expire + // Re-new ASPAs, if the renew_threshold is specified, then + // only objects which will expire before that time will be + // renewed. pub fn renew( &self, certified_key: &CertifiedKey, + renew_threshold: Option