pub struct Validator { /* private fields */ }Expand description
Validates Data packets against a trust schema and certificate chain.
The active TrustSchema is stored in an Arc<RwLock<TrustSchema>> so it
can be replaced or extended at runtime without rebuilding the validator.
Reads (hot path) acquire a shared lock; writes (management API) acquire an
exclusive lock.
Implementations§
Source§impl Validator
impl Validator
Sourcepub async fn validate_chain(&self, data: &Data) -> ValidationResult
pub async fn validate_chain(&self, data: &Data) -> ValidationResult
Validate a Data packet by walking the full certificate chain.
Verifies the Data’s signature, then walks up the chain — each
certificate’s signature is verified using the next certificate’s
public key — until a trust anchor is reached. Missing certificates
are fetched via the CertFetcher if configured.
Source§impl Validator
impl Validator
Sourcepub fn new(schema: TrustSchema) -> Self
pub fn new(schema: TrustSchema) -> Self
Create a validator with a private cert cache (no chain walking).
Sourcepub fn with_chain(
schema: TrustSchema,
cert_cache: Arc<CertCache>,
trust_anchors: Arc<DashMap<Arc<Name>, Certificate>>,
cert_fetcher: Option<Arc<CertFetcher>>,
max_chain: usize,
) -> Self
pub fn with_chain( schema: TrustSchema, cert_cache: Arc<CertCache>, trust_anchors: Arc<DashMap<Arc<Name>, Certificate>>, cert_fetcher: Option<Arc<CertFetcher>>, max_chain: usize, ) -> Self
Create a validator wired to shared infrastructure for chain walking.
Sourcepub fn cert_cache(&self) -> &CertCache
pub fn cert_cache(&self) -> &CertCache
Access the certificate cache.
Sourcepub fn add_trust_anchor(&self, cert: Certificate)
pub fn add_trust_anchor(&self, cert: Certificate)
Register a trust anchor.
Sourcepub fn is_trust_anchor(&self, name: &Name) -> bool
pub fn is_trust_anchor(&self, name: &Name) -> bool
Check if a name is a trust anchor.
Sourcepub fn set_schema(&self, schema: TrustSchema)
pub fn set_schema(&self, schema: TrustSchema)
Replace the active trust schema.
Takes effect immediately for all subsequent validations.
Sourcepub fn add_schema_rule(&self, rule: SchemaRule)
pub fn add_schema_rule(&self, rule: SchemaRule)
Append a rule to the active schema.
Sourcepub fn remove_schema_rule(&self, index: usize) -> Option<SchemaRule>
pub fn remove_schema_rule(&self, index: usize) -> Option<SchemaRule>
Remove the rule at index from the active schema.
Returns the removed rule, or None if index is out of bounds.
Sourcepub fn schema_rules_text(&self) -> Vec<(String, String)>
pub fn schema_rules_text(&self) -> Vec<(String, String)>
Snapshot the current schema rules as (data_pattern, key_pattern) text pairs.
Sourcepub fn schema_snapshot(&self) -> TrustSchema
pub fn schema_snapshot(&self) -> TrustSchema
Returns a clone of the current TrustSchema.
Sourcepub async fn validate(&self, data: &Data) -> ValidationResult
pub async fn validate(&self, data: &Data) -> ValidationResult
Validate a Data packet (single-hop, returns Pending if cert missing).
For full chain walking with async cert fetching, use validate_chain.