Skip to main content

FsCertStorage

Struct FsCertStorage 

Source
pub struct FsCertStorage {
    dir: PathBuf,
}

Fields§

§dir: PathBuf

Implementations§

Source§

impl FsCertStorage

Source

pub fn new(dir: impl Into<PathBuf>) -> Self

Source

fn cert_dir(&self, id: &CertId) -> PathBuf

Source

fn challenge_path(&self, domain: &str) -> PathBuf

Source

fn lease_path(&self, id: &CertId) -> PathBuf

Source

fn read_lease(&self, id: &CertId) -> Result<Option<LeaseFile>, AcmeError>

Source

fn write_lease( &self, id: &CertId, owner: &str, ttl: Duration, ) -> Result<(), AcmeError>

Source

fn create_lease_file( &self, id: &CertId, owner: &str, ttl: Duration, ) -> Result<()>

Creates the lease file iff it does not already exist, and never exposes a partially-written lease at lease_path: the full JSON is written to a private, unique temp file first, then published with hard_link, which — unlike creating the destination directly — fails atomically with AlreadyExists when the destination is already there (POSIX link(2), NTFS CreateHardLink) without ever making an empty or partial file visible at lease_path. The OS guarantees exactly one concurrent caller’s hard_link wins.

Falls back to the old create_new + write_all path only when hard_link itself errors with something other than AlreadyExists (e.g. unsupported on some network filesystem). That fallback has a reduced guarantee: the destination is briefly visible empty before the content lands, since content can no longer be written before the path is public.

Source

fn take_over_expired_lease( &self, id: &CertId, owner: &str, ttl: Duration, ) -> Result<bool, AcmeError>

Takes over a lease that read as expired (or corrupt), atomically with respect to every other contender.

The naive remove_opt + create_lease_file lets two contenders both win (A removes and creates; B, already past its own read, removes A’s fresh lease and creates its own). Moving the stale file aside with rename and creating in its place does not fix it either: between the rename and the create the lease path is empty, and a contender that reaches its own exclusive create in that window wins alongside the one doing the takeover.

So the takeover holds a separate mutex — an exclusively created <lease>.takeover marker, the one primitive the filesystem does give atomically — and installs the new lease by rename-over (via atomic_write), which replaces the file without the path ever being empty. Contenders that lose the marker concede for this round and re-evaluate on their next pass.

Trait Implementations§

Source§

impl CertStorage for FsCertStorage

Source§

fn label(&self) -> String

Operator-facing name shown in the Admin API (filesystem, store:<name>).
Source§

fn load_account<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn save_account<'life0, 'life1, 'async_trait>( &'life0 self, creds: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_cert<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 CertId, ) -> Pin<Box<dyn Future<Output = Result<Option<StoredCert>, AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn save_cert<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 CertId, cert: &'life2 StoredCert, ) -> Pin<Box<dyn Future<Output = Result<(), AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn put_challenge<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, domain: &'life1 str, key_auth: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Registers key_auth for domain; expires after ttl.
Source§

fn get_challenge<'life0, 'life1, 'async_trait>( &'life0 self, domain: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn remove_challenge<'life0, 'life1, 'async_trait>( &'life0 self, domain: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn try_acquire_lease<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 CertId, owner: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

true when this owner now holds the lease for id (fresh or already its own); false when another live owner holds it.
Source§

fn renew_lease<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 CertId, owner: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Extends the lease iff owner holds it.
Source§

fn release_lease<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 CertId, owner: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AcmeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Releases iff owner holds it (a no-op otherwise).

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> MaybeSend for T

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