new CertificateStorage()
The CertificateStorage class stores trusted anchors and has a verified
certificate cache, and an unverified certificate cache.
Methods
cacheUnverifiedCertificate(certificate)
Cache the unverified certificate for a period of time (5 minutes).
Parameters:
Name | Type | Description |
---|---|---|
certificate |
CertificateV2 | The certificate packet, which is copied. |
cacheVerifiedCertificate(certificate)
Cache the verified certificate a period of time (1 hour).
Parameters:
Name | Type | Description |
---|---|---|
certificate |
CertificateV2 | The certificate object, which is copied. |
findTrustedCertificate(interestForCertificate) → {CertificateV2}
Find a trusted certificate in the trust anchor container or in the
verified cache.
Parameters:
Name | Type | Description |
---|---|---|
interestForCertificate |
Interest | The Interest for the certificate. |
Returns:
The found certificate, or null if not found.
- Type
- CertificateV2
getTrustAnchors() → {TrustAnchorContainer}
Get the trust anchor container.
Returns:
The trust anchor container.
- Type
- TrustAnchorContainer
getUnverifiedCertificateCache() → {CertificateCacheV2}
Get the unverified certificate cache.
Returns:
The unverified certificate cache.
- Type
- CertificateCacheV2
getVerifiedCertificateCache() → {CertificateCacheV2}
Get the verified certificate cache.
Returns:
The verified certificate cache.
- Type
- CertificateCacheV2
isCertificateKnown(certificatePrefix) → {boolean}
Check if the certificate with the given name prefix exists in the verified
cache, the unverified cache, or in the set of trust anchors.
Parameters:
Name | Type | Description |
---|---|---|
certificatePrefix |
Name | The certificate name prefix. |
Returns:
True if the certificate is known.
- Type
- boolean
loadAnchor(groupId, certificate, path, refreshPeriod, isDirectory)
There are two forms of loadAnchor:
loadAnchor(groupId, certificate) - Load a static trust anchor. Static trust
anchors are permanently associated with the validator and never expire.
loadAnchor(groupId, path, refreshPeriod, isDirectory) - Load dynamic trust
anchors. Dynamic trust anchors are associated with the validator for as long
as the underlying trust anchor file (or set of files) exists.
Parameters:
Name | Type | Description |
---|---|---|
groupId |
String | The certificate group id. |
certificate |
CertificateV2 | The certificate to load as a trust anchor, which is copied. |
path |
String | The path to load the trust anchors. |
refreshPeriod |
number | The refresh time in milliseconds for the anchors under path. This must be positive. The relevant trust anchors will only be updated when find is called. |
isDirectory |
boolean | (optional) If true, then path is a directory. If false or omitted, it is a single file. |
resetAnchors()
Remove any previously loaded static or dynamic trust anchors.
resetVerifiedCertificates()
Remove any cached verified certificates.
setCacheNowOffsetMilliseconds_(nowOffsetMilliseconds)
Set the offset when the cache insert() and refresh() get the current time,
which should only be used for testing.
Parameters:
Name | Type | Description |
---|---|---|
nowOffsetMilliseconds |
number | The offset in milliseconds. |