pub struct CertPinStore { /* private fields */ }Expand description
Thread-safe store for peer certificate fingerprint pins.
§Verification Semantics
| Policy | Unknown peer | Fingerprint matches | Fingerprint mismatch |
|---|---|---|---|
| TrustOnFirstUse | PinnedNew (pin + accept) | Accepted | Mismatch |
| Strict | UnknownPeer (reject) | Accepted | Mismatch |
| Observe | Accepted | Accepted | Accepted (+counter) |
Implementations§
Source§impl CertPinStore
impl CertPinStore
Sourcepub fn pin(
&self,
peer_id: impl Into<String>,
fingerprint: CertFingerprint,
now_ms: u64,
)
pub fn pin( &self, peer_id: impl Into<String>, fingerprint: CertFingerprint, now_ms: u64, )
Pre-register a trusted fingerprint for a peer.
If the peer is already pinned this call is a no-op (existing pin preserved).
Sourcepub fn unpin(&self, peer_id: &str) -> bool
pub fn unpin(&self, peer_id: &str) -> bool
Remove a pinned peer.
Returns true if a pin was present and removed.
Sourcepub fn verify(
&self,
peer_id: &str,
fingerprint: &CertFingerprint,
now_ms: u64,
) -> VerificationResult
pub fn verify( &self, peer_id: &str, fingerprint: &CertFingerprint, now_ms: u64, ) -> VerificationResult
Verify a peer’s certificate fingerprint against the current policy.
Sourcepub fn get_pin(&self, peer_id: &str) -> Option<PeerCertPin>
pub fn get_pin(&self, peer_id: &str) -> Option<PeerCertPin>
Retrieve the pin info for a peer, if any.
Sourcepub fn pinned_peers(&self) -> Vec<String>
pub fn pinned_peers(&self) -> Vec<String>
Return a list of all pinned peer IDs.
Sourcepub fn mismatch_count(&self) -> u64
pub fn mismatch_count(&self) -> u64
Total fingerprint mismatches detected across all verifications.
Sourcepub fn tofu_count(&self) -> u64
pub fn tofu_count(&self) -> u64
Total TOFU pins created.
Sourcepub fn export_pins(&self) -> Vec<PeerCertPin>
pub fn export_pins(&self) -> Vec<PeerCertPin>
Export all pins as a serializable vector.
Sourcepub fn import_pins(&self, pins: Vec<PeerCertPin>)
pub fn import_pins(&self, pins: Vec<PeerCertPin>)
Import pins (merge). Existing pins are not overwritten.
Auto Trait Implementations§
impl !Freeze for CertPinStore
impl !RefUnwindSafe for CertPinStore
impl Send for CertPinStore
impl Sync for CertPinStore
impl Unpin for CertPinStore
impl UnsafeUnpin for CertPinStore
impl UnwindSafe for CertPinStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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