certificate-storage.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2022 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 
22 #ifndef NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
23 #define NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
24 
28 
29 namespace ndn {
30 namespace security {
31 inline namespace v2 {
32 
36 class CertificateStorage : noncopyable
37 {
38 public:
40 
48  const Certificate*
49  findTrustedCert(const Interest& interestForCert) const;
50 
54  bool
55  isCertKnown(const Name& certPrefix) const;
56 
63  void
65 
70  getTrustAnchors() const;
71 
75  const CertificateCache&
76  getVerifiedCertCache() const;
77 
81  const CertificateCache&
82  getUnverifiedCertCache() const;
83 
84 protected:
93  void
94  loadAnchor(const std::string& groupId, Certificate&& cert);
95 
107  void
108  loadAnchor(const std::string& groupId, const std::string& certfilePath,
109  time::nanoseconds refreshPeriod, bool isDir = false);
110 
114  void
115  resetAnchors();
116 
123  void
125 
129  void
131 
132 protected:
136 };
137 
138 } // inline namespace v2
139 } // namespace security
140 } // namespace ndn
141 
142 #endif // NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
Represents an Interest packet.
Definition: interest.hpp:50
Represents an absolute name.
Definition: name.hpp:44
Represents a container for verified certificates.
Storage for trusted anchors, verified certificate cache, and unverified certificate cache.
const Certificate * findTrustedCert(const Interest &interestForCert) const
Find a trusted certificate in trust anchor container or in verified cache.
void loadAnchor(const std::string &groupId, Certificate &&cert)
Load static trust anchor.
const CertificateCache & getUnverifiedCertCache() const
void resetVerifiedCerts()
Remove any cached verified certificates.
const TrustAnchorContainer & getTrustAnchors() const
void resetAnchors()
Remove any previously loaded static or dynamic trust anchor.
const CertificateCache & getVerifiedCertCache() const
void cacheVerifiedCert(Certificate &&cert)
Cache verified certificate a period of time (1 hour).
void cacheUnverifiedCert(Certificate &&cert)
Cache unverified certificate for a period of time (5 minutes).
bool isCertKnown(const Name &certPrefix) const
Check if certificate exists in the verified/unverified cache or in the set of trust anchors.
Represents an NDN certificate.
Definition: certificate.hpp:60
boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:50
Definition: data.cpp:25