ndn::security::CertificateStorage Class Reference

Storage for trusted anchors, verified certificate cache, and unverified certificate cache. More...

#include <ndn-cxx/security/certificate-storage.hpp>

+ Inheritance diagram for ndn::security::CertificateStorage:
+ Collaboration diagram for ndn::security::CertificateStorage:

Public Member Functions

 CertificateStorage ()
 
void cacheUnverifiedCert (Certificate &&cert)
 Cache unverified certificate for a period of time (5 minutes). More...
 
const CertificatefindTrustedCert (const Interest &interestForCert) const
 Find a trusted certificate in trust anchor container or in verified cache. More...
 
const TrustAnchorContainergetTrustAnchors () const
 
const CertificateCachegetUnverifiedCertCache () const
 
const CertificateCachegetVerifiedCertCache () const
 
bool isCertKnown (const Name &certPrefix) const
 Check if certificate exists in the verified/unverified cache or in the set of trust anchors. More...
 

Protected Member Functions

void cacheVerifiedCert (Certificate &&cert)
 Cache verified certificate a period of time (1 hour). More...
 
void loadAnchor (const std::string &groupId, Certificate &&cert)
 Load static trust anchor. More...
 
void loadAnchor (const std::string &groupId, const std::string &certfilePath, time::nanoseconds refreshPeriod, bool isDir=false)
 Load dynamic trust anchors. More...
 
void resetAnchors ()
 Remove any previously loaded static or dynamic trust anchor. More...
 
void resetVerifiedCerts ()
 Remove any cached verified certificates. More...
 

Protected Attributes

TrustAnchorContainer m_trustAnchors
 
CertificateCache m_unverifiedCertCache
 
CertificateCache m_verifiedCertCache
 

Detailed Description

Storage for trusted anchors, verified certificate cache, and unverified certificate cache.

Definition at line 34 of file certificate-storage.hpp.

Constructor & Destructor Documentation

◆ CertificateStorage()

ndn::security::CertificateStorage::CertificateStorage ( )

Definition at line 26 of file certificate-storage.cpp.

Member Function Documentation

◆ cacheUnverifiedCert()

void ndn::security::CertificateStorage::cacheUnverifiedCert ( Certificate &&  cert)

Cache unverified certificate for a period of time (5 minutes).

Parameters
certThe certificate packet
Todo:
Add ability to customize time period

Definition at line 81 of file certificate-storage.cpp.

◆ cacheVerifiedCert()

void ndn::security::CertificateStorage::cacheVerifiedCert ( Certificate &&  cert)
protected

Cache verified certificate a period of time (1 hour).

Parameters
certThe certificate packet
Todo:
Add ability to customize time period

Definition at line 69 of file certificate-storage.cpp.

◆ findTrustedCert()

const Certificate * ndn::security::CertificateStorage::findTrustedCert ( const Interest interestForCert) const

Find a trusted certificate in trust anchor container or in verified cache.

Parameters
interestForCertInterest for certificate
Returns
Found certificate, nullptr if not found.
Note
The returned pointer may get invalidated after next findTrustedCert() or findCert() calls.

Definition at line 33 of file certificate-storage.cpp.

◆ getTrustAnchors()

const TrustAnchorContainer & ndn::security::CertificateStorage::getTrustAnchors ( ) const
Returns
Trust anchor container

Definition at line 87 of file certificate-storage.cpp.

◆ getUnverifiedCertCache()

const CertificateCache & ndn::security::CertificateStorage::getUnverifiedCertCache ( ) const
Returns
Unverified certificate cache

Definition at line 99 of file certificate-storage.cpp.

◆ getVerifiedCertCache()

const CertificateCache & ndn::security::CertificateStorage::getVerifiedCertCache ( ) const
Returns
Verified certificate cache

Definition at line 93 of file certificate-storage.cpp.

◆ isCertKnown()

bool ndn::security::CertificateStorage::isCertKnown ( const Name certPrefix) const

Check if certificate exists in the verified/unverified cache or in the set of trust anchors.

Definition at line 42 of file certificate-storage.cpp.

◆ loadAnchor() [1/2]

void ndn::security::CertificateStorage::loadAnchor ( const std::string &  groupId,
Certificate &&  cert 
)
protected

Load static trust anchor.

Static trust anchors are permanently associated with the validator and never expire.

Parameters
groupIdCertificate group id.
certCertificate to load as a trust anchor.

Definition at line 50 of file certificate-storage.cpp.

◆ loadAnchor() [2/2]

void ndn::security::CertificateStorage::loadAnchor ( const std::string &  groupId,
const std::string &  certfilePath,
time::nanoseconds  refreshPeriod,
bool  isDir = false 
)
protected

Load dynamic trust anchors.

Dynamic trust anchors are associated with the validator for as long as the underlying trust anchor file (set of files) exist(s).

Parameters
groupIdCertificate group id, must not be empty.
certfilePathSpecifies the path to load the trust anchors.
refreshPeriodRefresh period for the trust anchors, must be positive.
isDirTells whether the path is a directory or a single file.

Definition at line 56 of file certificate-storage.cpp.

◆ resetAnchors()

void ndn::security::CertificateStorage::resetAnchors ( )
protected

Remove any previously loaded static or dynamic trust anchor.

Definition at line 63 of file certificate-storage.cpp.

◆ resetVerifiedCerts()

void ndn::security::CertificateStorage::resetVerifiedCerts ( )
protected

Remove any cached verified certificates.

Definition at line 75 of file certificate-storage.cpp.

Member Data Documentation

◆ m_trustAnchors

TrustAnchorContainer ndn::security::CertificateStorage::m_trustAnchors
protected

Definition at line 131 of file certificate-storage.hpp.

◆ m_unverifiedCertCache

CertificateCache ndn::security::CertificateStorage::m_unverifiedCertCache
protected

Definition at line 133 of file certificate-storage.hpp.

◆ m_verifiedCertCache

CertificateCache ndn::security::CertificateStorage::m_verifiedCertCache
protected

Definition at line 132 of file certificate-storage.hpp.