Skip to main content

StarManager

Struct StarManager 

Source
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

Source

pub fn new(config: StarConfig) -> Self

Create a new StarManager with the given configuration.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn active_order_count(&self) -> usize

Count of currently active (not cancelled/completed/expired) orders.

Source

pub fn orders_needing_renewal(&self) -> Vec<String>

Return order IDs that need a renewal certificate issued.

An order needs renewal when:

  1. Its status is Active.
  2. It has not exhausted max_renewals.
  3. 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.

Source

pub fn get_order(&self, star_id: &str) -> Option<StarOrder>

Retrieve a clone of a STAR order by ID.

Returns None if the order does not exist.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,