NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
certificate-fetcher.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2020 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
#include "
ndn-cxx/security/certificate-fetcher.hpp
"
23
#include "
ndn-cxx/security/certificate-request.hpp
"
24
#include "
ndn-cxx/security/certificate-storage.hpp
"
25
#include "
ndn-cxx/security/validation-state.hpp
"
26
#include "
ndn-cxx/util/logger.hpp
"
27
28
namespace
ndn
{
29
namespace
security
{
30
inline
namespace
v2 {
31
32
NDN_LOG_INIT
(
ndn
.
security
.CertificateFetcher);
33
34
#define NDN_LOG_DEBUG_DEPTH(x) NDN_LOG_DEBUG(std::string(state->getDepth() + 1, '>') << " " << x)
35
36
CertificateFetcher::CertificateFetcher
()
37
: m_certStorage(nullptr)
38
{
39
}
40
41
CertificateFetcher::~CertificateFetcher
() =
default
;
42
43
void
44
CertificateFetcher::setCertificateStorage
(
CertificateStorage
& certStorage)
45
{
46
m_certStorage
= &certStorage;
47
}
48
49
void
50
CertificateFetcher::fetch
(
const
shared_ptr<CertificateRequest>& certRequest,
51
const
shared_ptr<ValidationState>& state,
52
const
ValidationContinuation
& continueValidation)
53
{
54
BOOST_ASSERT(
m_certStorage
!=
nullptr
);
55
auto
cert =
m_certStorage
->
getUnverifiedCertCache
().
find
(certRequest->interest);
56
if
(cert !=
nullptr
) {
57
NDN_LOG_DEBUG_DEPTH
(
"Found certificate in **un**verified key cache "
<< cert->getName());
58
continueValidation(*cert, state);
59
return
;
60
}
61
62
doFetch(certRequest, state,
63
[continueValidation,
this
] (
const
Certificate
& cert,
const
shared_ptr<ValidationState>& state) {
64
m_certStorage
->
cacheUnverifiedCert
(
Certificate
(cert));
65
continueValidation(cert, state);
66
});
67
}
68
69
}
// inline namespace v2
70
}
// namespace security
71
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::v2::Certificate
Represents an NDN certificate following the version 2.0 format.
Definition:
certificate.hpp:60
ndn::security::v2::CertificateCache::find
const Certificate * find(const Name &certPrefix) const
Get certificate given key name.
Definition:
certificate-cache.cpp:67
ndn::security::v2::CertificateFetcher::m_certStorage
CertificateStorage * m_certStorage
Definition:
certificate-fetcher.hpp:84
ndn::security::v2::CertificateStorage::cacheUnverifiedCert
void cacheUnverifiedCert(Certificate &&cert)
Cache unverified certificate for a period of time (5 minutes)
Definition:
certificate-storage.cpp:86
ndn::security::v2::CertificateFetcher::ValidationContinuation
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
Definition:
certificate-fetcher.hpp:43
validation-state.hpp
logger.hpp
ndn::security::v2::CertificateFetcher::CertificateFetcher
CertificateFetcher()
Definition:
certificate-fetcher.cpp:36
ndn::security::v2::CertificateStorage::getUnverifiedCertCache
const CertificateCache & getUnverifiedCertCache() const
Definition:
certificate-storage.cpp:104
ndn::security::v2::CertificateStorage
Storage for trusted anchors, verified certificate cache, and unverified certificate cache...
Definition:
certificate-storage.hpp:36
ndn::security::v2::CertificateFetcher::fetch
void fetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Asynchronously fetch certificate.
Definition:
certificate-fetcher.cpp:50
ndn::security
Definition:
dummy-keychain.cpp:28
certificate-request.hpp
NDN_LOG_DEBUG_DEPTH
#define NDN_LOG_DEBUG_DEPTH(x)
Definition:
certificate-fetcher.cpp:34
NDN_LOG_INIT
#define NDN_LOG_INIT(name)
declare a log module
Definition:
logger.hpp:81
ndn::security::v2::CertificateFetcher::~CertificateFetcher
virtual ~CertificateFetcher()
certificate-fetcher.hpp
ndn::security::v2::CertificateFetcher::setCertificateStorage
virtual void setCertificateStorage(CertificateStorage &certStorage)
Assign certificate storage to check known certificate and to cache unverified ones.
Definition:
certificate-fetcher.cpp:44
certificate-storage.hpp
ndnSIM
ndn-cxx
ndn-cxx
security
certificate-fetcher.cpp
Generated on Fri May 6 2022 12:34:12 for ndnSIM by
1.8.13