ndn-cxx: NDN C++ Library 0.9.0-33-g832ea91d
Loading...
Searching...
No Matches
certificate-storage.cpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2023 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
23
24namespace ndn::security {
25
27 : m_verifiedCertCache(1_h)
28 , m_unverifiedCertCache(5_min)
29{
30}
31
32const Certificate*
33CertificateStorage::findTrustedCert(const Interest& interestForCert) const
34{
35 if (auto cert = m_trustAnchors.find(interestForCert); cert != nullptr) {
36 return cert;
37 }
38 return m_verifiedCertCache.find(interestForCert);
39}
40
41bool
43{
44 return m_trustAnchors.find(certName) != nullptr ||
45 m_verifiedCertCache.find(certName) != nullptr ||
46 m_unverifiedCertCache.find(certName) != nullptr;
47}
48
49void
50CertificateStorage::loadAnchor(const std::string& groupId, Certificate&& cert)
51{
52 m_trustAnchors.insert(groupId, std::move(cert));
53}
54
55void
56CertificateStorage::loadAnchor(const std::string& groupId, const std::string& certfilePath,
57 time::nanoseconds refreshPeriod, bool isDir)
58{
59 m_trustAnchors.insert(groupId, certfilePath, refreshPeriod, isDir);
60}
61
62void
67
68void
73
74void
79
80void
85
91
97
103
104} // namespace ndn::security
Represents an Interest packet.
Definition interest.hpp:50
Represents an absolute name.
Definition name.hpp:45
Represents a container for verified certificates.
void insert(const Certificate &cert)
Insert certificate into cache.
const Certificate * find(const Name &certPrefix) const
Get certificate given key name.
void clear()
Remove all certificates from cache.
const Certificate * findTrustedCert(const Interest &interestForCert) const
Find a trusted certificate in trust anchor container or in verified cache.
void cacheUnverifiedCert(Certificate &&cert)
Cache unverified certificate for a period of time (5 minutes).
const TrustAnchorContainer & getTrustAnchors() const
void resetAnchors()
Remove any previously loaded static or dynamic trust anchor.
void cacheVerifiedCert(Certificate &&cert)
Cache verified certificate a period of time (1 hour).
bool isCertKnown(const Name &certPrefix) const
Check if certificate exists in the verified/unverified cache or in the set of trust anchors.
const CertificateCache & getVerifiedCertCache() const
void loadAnchor(const std::string &groupId, Certificate &&cert)
Load static trust anchor.
void resetVerifiedCerts()
Remove any cached verified certificates.
const CertificateCache & getUnverifiedCertCache() const
Represents an NDN certificate.
const Certificate * find(const Name &keyName) const
Search for certificate across all groups (longest prefix match).
void insert(const std::string &groupId, Certificate &&cert)
Insert a static trust anchor.
void clear()
Remove all static or dynamic anchors.
Contains the ndn-cxx security framework.
::boost::chrono::nanoseconds nanoseconds
Definition time.hpp:54