pub struct CertChain {
pub intermediates: Vec<SignedCredential>,
pub leaf: SignedCredential,
}Expand description
A presented certificate chain: zero or more intermediate CA certs plus the leaf (node) credential.
Fields§
§intermediates: Vec<SignedCredential>Intermediate CA certs, ordered anchor-first: intermediates[0]
is signed by a trusted root in the receiver’s bundle; each subsequent
cert is signed by the previous one; the last signed the leaf. Empty
⇒ the leaf is signed directly by a trusted root (the P2/P3 one-level
case, preserved for back-compat).
leaf: SignedCredentialThe leaf (node) credential whose subject_pubkey the caller will use
as the peer’s verifying key once the chain verifies.
Implementations§
Source§impl CertChain
impl CertChain
Sourcepub fn new(leaf: SignedCredential, intermediates: Vec<SignedCredential>) -> Self
pub fn new(leaf: SignedCredential, intermediates: Vec<SignedCredential>) -> Self
A chain with an explicit leaf and intermediates (anchor-first).
Sourcepub fn direct(leaf: SignedCredential) -> Self
pub fn direct(leaf: SignedCredential) -> Self
A one-level chain: the leaf is signed directly by a trusted root.
Sourcepub fn intermediates_header_value(
&self,
) -> Result<Option<String>, CredentialError>
pub fn intermediates_header_value( &self, ) -> Result<Option<String>, CredentialError>
Encode the anchor-first intermediates as the CHAIN_HEADER value
(v1=<base64(CBOR array of credential wire envelopes)>), or None
when the chain is one-level (no intermediates ⇒ no chain header, so a
hierarchical sender degrades to the exact P2/P3 wire when it happens to
hold a root-signed leaf). The leaf is encoded separately via
SignedCredential::to_header_value into the credential header.
§Errors
CredentialError::Malformed on an internal serialisation fault.
Sourcepub fn intermediates_from_header_value(
value: &str,
) -> Result<Vec<SignedCredential>, CredentialError>
pub fn intermediates_from_header_value( value: &str, ) -> Result<Vec<SignedCredential>, CredentialError>
Parse a CHAIN_HEADER value (v1=<base64(CBOR array)>) into the
anchor-first intermediates list. Pair with a leaf parsed from the
credential header to reconstruct a CertChain via Self::new.
§Errors
CredentialError::Malformed on a missing prefix, bad base64, or a
structurally invalid CBOR array / envelope.
Sourcepub fn verify(
&self,
bundle: &TrustBundle,
now_unix: i64,
max_depth: usize,
) -> Result<FederationCredential, ChainError>
pub fn verify( &self, bundle: &TrustBundle, now_unix: i64, max_depth: usize, ) -> Result<FederationCredential, ChainError>
Verify the whole chain against bundle at now_unix, rejecting
chains deeper than max_depth. On success returns the verified leaf
FederationCredential whose subject_pubkey is the peer’s key.
Identity-binding (does the leaf’s subject_agent_id match the wire
peer_id?) and delegation-authority (may this intermediate vouch for
this leaf’s namespace?) stay the caller’s responsibility — the same
crypto/policy split as SignedCredential::verify_against.
§Errors
ChainError::ChainTooDeepwhendepth() > max_depth.ChainError::NameMismatch/ChainError::DomainMismatchon a broken name or domain link.ChainError::Linkwrapping any credential-layer failure (anchor not in bundle, bad signature, expired, etc.).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CertChain
impl RefUnwindSafe for CertChain
impl Send for CertChain
impl Sync for CertChain
impl Unpin for CertChain
impl UnsafeUnpin for CertChain
impl UnwindSafe for CertChain
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
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