Skip to main content

IdentitySource

Struct IdentitySource 

Source
pub struct IdentitySource { /* private fields */ }
Expand description

Where an identity comes from, and the identity of the moment.

Cloning shares the source. Equality is what the connection pool keys on: two static sources holding the same identity are equal, every other source is equal only to itself.

Implementations§

Source§

impl IdentitySource

Source

pub fn from_identity(identity: Identity) -> Result<IdentitySource, Error>

A source that holds identity and never changes.

Fails when the material cannot be read or parsed, which is where a wrong path is caught: before a binding or a dial, not during a handshake.

Source

pub fn ephemeral( names: impl IntoIterator<Item = impl Into<String>>, ) -> Result<IdentitySource, Error>

A self-signed identity generated in memory for names, gone with the process: the default, and what a peer that pins by address needs.

Source

pub fn external(initial: Identity) -> Result<IdentitySource, Error>

A source driven from outside: starts as initial and changes on IdentitySource::update. What an issuing client uses.

Source

pub fn files( dir: impl Into<PathBuf>, options: FilesOptions, ) -> Result<IdentitySource, Error>

A directory holding cert.pem and key.pem, reloaded when either changes.

When neither file exists and the generate feature is on, a self-signed identity for options.names is written there first — the directory 0700, both files 0600 on Unix — so a second start finds the same key and the same fingerprint. Without the feature an empty directory is an error. A directory with one of the two files is an error in either case: half an identity is not one to bootstrap over.

This is also how every external issuer that writes files plugs in — a Vault Agent template, cert-manager, certbot --reuse-key, a SPIRE agent: replace the files and the next use of the identity picks them up (0032 §4.2). Replace both atomically, or the certificate first and the key second, so no check sees a chain that does not match its key.

Source

pub fn current(&self) -> Identity

The identity of the moment.

On a file source this is also where a due modification-time check runs, so a caller pays it at most once per poll interval.

Source

pub fn fingerprint(&self) -> Result<Fingerprint, Error>

The fingerprint of the current key.

Fails only on a static value whose material cannot be read; every other source checked it when it loaded.

Source

pub fn update(&self, identity: Identity) -> Result<(), Error>

Replaces the identity. Renewed when the key is unchanged, KeyChanged when it is not.

Fails, and changes nothing, when the material cannot be read: a renewal that delivered garbage leaves the previous identity in service and reports RenewalFailed.

Source

pub fn report_failure(&self, reason: impl Into<String>)

Reports a failed renewal that never produced material, from an external source. The identity in service is unchanged.

Source

pub fn report_handoff_stolen(&self)

Reports that this process’s hand-off credential had already been redeemed (0032 §2). The identity in service is unchanged; the caller is expected not to continue.

Source

pub fn reload(&self) -> Result<bool, Error>

Reloads a file source now, regardless of the poll interval.

Ok(true) when the files had changed and were loaded, Ok(false) when nothing changed, and an error — also reported as RenewalFailed — when they changed and could not be loaded. Not a file source: Ok(false).

Source

pub fn events(&self) -> IdentityEvents

The event stream of this source; each call is an independent reader.

Source

pub fn downgrade(&self) -> WeakIdentitySource

A weak handle to this source, for a background task that must end when the application drops its last strong handle. See WeakIdentitySource.

Trait Implementations§

Source§

impl Clone for IdentitySource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IdentitySource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for IdentitySource

Source§

impl From<Identity> for IdentitySource

Source§

fn from(identity: Identity) -> IdentitySource

A static source. The material is read at first use rather than here: From cannot fail, and a wrong path is still caught before any handshake, by the bind or the dial that first needs the key.

Source§

impl From<IdentitySource> for ServerTls

Source§

fn from(identity: IdentitySource) -> ServerTls

Converts to this type from the input type.
Source§

impl Hash for IdentitySource

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for IdentitySource

Source§

fn eq(&self, other: &IdentitySource) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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