new Validator(policy, certificateFetcher)
The Validator class provides an interface for validating data and interest
packets.
Every time a validation process is initiated, it creates a ValidationState
that exists until the validation finishes with either success or failure.
This state serves several purposes:
to record the Interest or Data packet being validated,
to record the failure callback,
to record certificates in the certification chain for the Interest or Data
packet being validated,
to record the names of the requested certificates in order to detect loops in
the certificate chain,
and to keep track of the validation chain size (also known as the validation
"depth").
During validation, the policy and/or key fetcher can augment the validation
state with policy- and fetcher-specific information using tags.
A Validator has a trust anchor cache to save static and dynamic trust
anchors, a verified certificate cache for saving certificates that are
already verified, and an unverified certificate cache for saving pre-fetched
but not yet verified certificates.
Create a Validator with the policy and fetcher.
Parameters:
Name | Type | Description |
---|---|---|
policy |
ValidationPolicy | The validation policy to be associated with this validator. |
certificateFetcher |
CertificateFetcher | (optional) The certificate fetcher implementation. If omitted, use a CertificateFetcherOffline (assuming that the validation policy doesn't need to fetch certificates). |
- Source:
Methods
getFetcher() → {CertificateFetcher}
Get the CertificateFetcher given to (or created in) the constructor.
- Source:
Returns:
The CertificateFetcher.
- Type
- CertificateFetcher
getMaxDepth() → {number}
Get the maximum depth of the certificate chain.
- Source:
Returns:
The maximum depth.
- Type
- number
getPolicy() → {ValidationPolicy}
Get the ValidationPolicy given to the constructor.
- Source:
Returns:
The ValidationPolicy.
- Type
- ValidationPolicy
requestCertificate_(certificateRequest, state)
Request a certificate for further validation.
Parameters:
Name | Type | Description |
---|---|---|
certificateRequest |
CertificateRequest | The certificate request. |
state |
ValidationState | The current validation state. |
- Source:
setMaxDepth(maxDepth)
Set the maximum depth of the certificate chain.
Parameters:
Name | Type | Description |
---|---|---|
maxDepth |
number | The maximum depth. |
- Source:
validate(dataOrInterest, successCallback, failureCallback)
Asynchronously validate the Data or Interest packet.
Parameters:
Name | Type | Description |
---|---|---|
dataOrInterest |
Data | Interest | The Data or Interest packet to validate, which is copied. |
successCallback |
function | On validation success, this calls successCallback(dataOrInterest). |
failureCallback |
function | On validation failure, this calls failureCallback(dataOrInterest, error) where error is a ValidationError. |
- Source:
validateCertificate_(certificate, state)
Recursively validate the certificates in the certification chain.
Parameters:
Name | Type | Description |
---|---|---|
certificate |
CertificateV2 | The certificate to check. |
state |
ValidationState | The current validation state. |
- Source: