pub struct StarManager { /* private fields */ }Expand description
Manages STAR orders and certificate renewal state.
StarManager is the server-side implementation of the STAR protocol
(RFC 8739). It tracks active orders in a concurrent map and provides
methods for the renewal loop to query which orders need new certificates.
Implementations§
Source§impl StarManager
impl StarManager
Sourcepub fn new(config: StarConfig) -> Self
pub fn new(config: StarConfig) -> Self
Create a new StarManager with the given configuration.
Sourcepub fn create_order(
&self,
subject_dn: String,
key_type: String,
profile: String,
renewal_interval_secs: u64,
lifetime_days: u32,
ca_id: String,
csr_der: Vec<u8>,
requestor_dn: Option<String>,
) -> Result<StarOrder, StarError>
pub fn create_order( &self, subject_dn: String, key_type: String, profile: String, renewal_interval_secs: u64, lifetime_days: u32, ca_id: String, csr_der: Vec<u8>, requestor_dn: Option<String>, ) -> Result<StarOrder, StarError>
Create a new STAR order.
Validates the renewal interval against configured bounds, checks the active-order limit, and computes the total number of renewals from the requested lifetime.
RFC 8739 §3.1: the server MUST validate auto-renewal-lifetime and
auto-renewal-end-date against its policy before accepting the order.
Sourcepub fn get_current_certificate(
&self,
star_id: &str,
) -> Result<StarCertificate, StarError>
pub fn get_current_certificate( &self, star_id: &str, ) -> Result<StarCertificate, StarError>
Retrieve the current certificate for a STAR order.
RFC 8739 §3.3: clients GET the STAR certificate URL to obtain the latest renewal.
Sourcepub fn store_renewed_certificate(
&self,
star_id: &str,
cert: StarCertificate,
) -> Result<(), StarError>
pub fn store_renewed_certificate( &self, star_id: &str, cert: StarCertificate, ) -> Result<(), StarError>
Store a newly renewed certificate in the order.
Increments the renewal counter and transitions the order to
Completed if max_renewals has been reached.
Sourcepub fn cancel_order(&self, star_id: &str) -> Result<(), StarError>
pub fn cancel_order(&self, star_id: &str) -> Result<(), StarError>
Cancel a STAR order.
RFC 8739 §3.1.2: the subscriber or IdO may cancel an active order. After cancellation, no further certificates are issued.
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Remove orders whose lifetime_end has passed.
Should be called periodically (e.g., from a background task) to
reclaim memory. Orders past their lifetime are marked Expired
first, then removed entirely.
Returns the number of orders that were cleaned up.
Sourcepub fn active_order_count(&self) -> usize
pub fn active_order_count(&self) -> usize
Count of currently active (not cancelled/completed/expired) orders.
Sourcepub fn orders_needing_renewal(&self) -> Vec<String>
pub fn orders_needing_renewal(&self) -> Vec<String>
Return order IDs that need a renewal certificate issued.
An order needs renewal when:
- Its status is
Active. - It has not exhausted
max_renewals. - The current certificate’s expiry minus the pre-renewal window is in the past (or no certificate has been issued yet).
The pre-renewal window is renewal_interval * pre_renewal_factor.
For example, with a 24-hour interval and factor 0.5, renewal
triggers when 12 hours remain on the current certificate.
Auto Trait Implementations§
impl Freeze for StarManager
impl !RefUnwindSafe for StarManager
impl Send for StarManager
impl Sync for StarManager
impl Unpin for StarManager
impl UnsafeUnpin for StarManager
impl UnwindSafe for StarManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more