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-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 
22 #ifndef NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
23 #define NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
24 
28 
29 namespace ndn::security {
30 
34 class CertificateStorage : noncopyable
35 {
36 public:
38 
46  const Certificate*
47  findTrustedCert(const Interest& interestForCert) const;
48 
52  bool
53  isCertKnown(const Name& certPrefix) const;
54 
61  void
63 
68  getTrustAnchors() const;
69 
73  const CertificateCache&
74  getVerifiedCertCache() const;
75 
79  const CertificateCache&
80  getUnverifiedCertCache() const;
81 
82 protected:
91  void
92  loadAnchor(const std::string& groupId, Certificate&& cert);
93 
105  void
106  loadAnchor(const std::string& groupId, const std::string& certfilePath,
107  time::nanoseconds refreshPeriod, bool isDir = false);
108 
112  void
113  resetAnchors();
114 
121  void
123 
127  void
129 
130 protected:
134 };
135 
136 } // namespace ndn::security
137 
138 #endif // NDN_CXX_SECURITY_CERTIFICATE_STORAGE_HPP
Represents an Interest packet.
Definition: interest.hpp:50
Represents an absolute name.
Definition: name.hpp:45
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 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.
Definition: certificate.hpp:58
Contains the ndn-cxx security framework.
::boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:54