blob: 32e29df703b5ea0900b7e09036f475b9ba2ce4ce [file] [log] [blame]
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento0dc02012021-11-23 22:55:03 -05002/*
Tianyuan Yu13aac732022-03-03 20:59:54 -08003 * Copyright (c) 2017-2022, Regents of the University of California.
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -07004 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert 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 General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
tylerliu4140fe82021-01-27 15:45:44 -080021#include "requester-request.hpp"
Davide Pesavento0dc02012021-11-23 22:55:03 -050022
Zhiyi Zhang84e11842020-11-19 20:03:23 -080023#include "challenge/challenge-module.hpp"
Zhiyi Zhangdc25ddf2020-10-20 14:28:55 -070024#include "detail/crypto-helpers.hpp"
Zhiyi Zhang062be6d2020-10-14 17:13:43 -070025#include "detail/challenge-encoder.hpp"
26#include "detail/error-encoder.hpp"
27#include "detail/info-encoder.hpp"
Zhiyi Zhang7cca76a2021-02-17 14:57:42 -080028#include "detail/request-encoder.hpp"
Zhiyi Zhang062be6d2020-10-14 17:13:43 -070029#include "detail/probe-encoder.hpp"
Davide Pesavento0dc02012021-11-23 22:55:03 -050030
31#include <ndn-cxx/metadata-object.hpp>
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070032#include <ndn-cxx/security/signing-helpers.hpp>
33#include <ndn-cxx/security/transform/base64-encode.hpp>
34#include <ndn-cxx/security/transform/buffer-source.hpp>
35#include <ndn-cxx/security/transform/stream-sink.hpp>
36#include <ndn-cxx/security/verification-helpers.hpp>
37#include <ndn-cxx/util/io.hpp>
38#include <ndn-cxx/util/random.hpp>
Davide Pesavento0dc02012021-11-23 22:55:03 -050039
tylerliu96a67e82020-10-15 13:37:12 -070040#include <boost/lexical_cast.hpp>
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070041
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040042namespace ndncert::requester {
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070043
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -070044NDN_LOG_INIT(ndncert.client);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070045
Davide Pesavento0dc02012021-11-23 22:55:03 -050046std::shared_ptr<Interest>
tylerliu4140fe82021-01-27 15:45:44 -080047Request::genCaProfileDiscoveryInterest(const Name& caName)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070048{
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070049 Name contentName = caName;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070050 if (readString(caName.at(-1)) != "CA")
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070051 contentName.append("CA");
52 contentName.append("INFO");
Davide Pesavento0dc02012021-11-23 22:55:03 -050053 return std::make_shared<Interest>(ndn::MetadataObject::makeDiscoveryInterest(contentName));
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070054}
55
Davide Pesavento0dc02012021-11-23 22:55:03 -050056std::shared_ptr<Interest>
tylerliu4140fe82021-01-27 15:45:44 -080057Request::genCaProfileInterestFromDiscoveryResponse(const Data& reply)
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070058{
Davide Pesavento0dc02012021-11-23 22:55:03 -050059 auto metaData = ndn::MetadataObject(reply);
Davide Pesavento64d5c8f2022-03-07 22:06:22 -050060 auto interestName = metaData.getVersionedName();
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070061 interestName.appendSegment(0);
Davide Pesavento64d5c8f2022-03-07 22:06:22 -050062 return std::make_shared<Interest>(interestName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070063}
64
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040065std::optional<CaProfile>
tylerliu4140fe82021-01-27 15:45:44 -080066Request::onCaProfileResponse(const Data& reply)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070067{
Zhiyi Zhangf22ae242020-11-17 10:51:15 -080068 auto caItem = infotlv::decodeDataContent(reply.getContent());
Davide Pesavento0dc02012021-11-23 22:55:03 -050069 if (!ndn::security::verifySignature(reply, *caItem.cert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -070070 NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
tylerliu41c11532020-10-10 16:14:45 -070071 NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070072 }
73 return caItem;
74}
75
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040076std::optional<CaProfile>
tylerliu4140fe82021-01-27 15:45:44 -080077Request::onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName)
Zhiyi Zhang837406d2020-10-05 22:01:31 -070078{
Zhiyi Zhangf22ae242020-11-17 10:51:15 -080079 auto caItem = infotlv::decodeDataContent(reply.getContent());
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080080 auto certBlock = caItem.cert->wireEncode();
Davide Pesavento0dc02012021-11-23 22:55:03 -050081 caItem.cert = std::make_shared<Certificate>(certBlock);
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080082 if (caItem.cert->getFullName() != caCertFullName) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -070083 NDN_LOG_ERROR("Ca profile does not match the certificate information offered by the original CA.");
tylerliu41c11532020-10-10 16:14:45 -070084 NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
Zhiyi Zhang837406d2020-10-05 22:01:31 -070085 }
86 return onCaProfileResponse(reply);
87}
88
Davide Pesavento0dc02012021-11-23 22:55:03 -050089std::shared_ptr<Interest>
tylerliu4140fe82021-01-27 15:45:44 -080090Request::genProbeInterest(const CaProfile& ca, std::multimap<std::string, std::string>&& probeInfo)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070091{
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080092 Name interestName = ca.caPrefix;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070093 interestName.append("CA").append("PROBE");
Davide Pesavento0dc02012021-11-23 22:55:03 -050094 auto interest = std::make_shared<Interest>(interestName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070095 interest->setMustBeFresh(true);
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040096 interest->setApplicationParameters(probetlv::encodeApplicationParameters(probeInfo));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -070097 return interest;
98}
99
100void
tylerliu4140fe82021-01-27 15:45:44 -0800101Request::onProbeResponse(const Data& reply, const CaProfile& ca,
102 std::vector<std::pair<Name, int>>& identityNames, std::vector<Name>& otherCas)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700103{
Davide Pesavento0dc02012021-11-23 22:55:03 -0500104 if (!ndn::security::verifySignature(reply, *ca.cert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700105 NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
tylerliu41c11532020-10-10 16:14:45 -0700106 NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700107 }
108 processIfError(reply);
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800109 probetlv::decodeDataContent(reply.getContent(), identityNames, otherCas);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700110}
111
Davide Pesavento0dc02012021-11-23 22:55:03 -0500112Request::Request(ndn::KeyChain& keyChain, const CaProfile& profile, RequestType requestType)
113 : m_caProfile(profile)
114 , m_type(requestType)
115 , m_keyChain(keyChain)
116{
117}
tylerliu4140fe82021-01-27 15:45:44 -0800118
Davide Pesavento0dc02012021-11-23 22:55:03 -0500119std::shared_ptr<Interest>
Tianyuan Yuca23bb02022-03-09 14:09:14 -0800120Request::genNewInterest(const Name& keyName,
tylerliu4140fe82021-01-27 15:45:44 -0800121 const time::system_clock::TimePoint& notBefore,
122 const time::system_clock::TimePoint& notAfter)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700123{
Tianyuan Yuca23bb02022-03-09 14:09:14 -0800124 if (!m_caProfile.caPrefix.isPrefixOf(keyName)) {
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700125 return nullptr;
126 }
Tianyuan Yuca23bb02022-03-09 14:09:14 -0800127 if (keyName.empty()) {
128 return nullptr;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700129 }
130 else {
Tianyuan Yuca23bb02022-03-09 14:09:14 -0800131 const auto& pib = m_keyChain.getPib();
132 ndn::security::pib::Identity identity;
133 m_identityName = ndn::security::extractIdentityFromKeyName(keyName);
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800134 identity = pib.getIdentity(m_identityName);
Tianyuan Yuca23bb02022-03-09 14:09:14 -0800135 m_keyPair = identity.getKey(keyName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700136 }
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700137
138 // generate certificate request
Davide Pesavento0dc02012021-11-23 22:55:03 -0500139 Certificate certRequest;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700140 certRequest.setName(Name(keyName).append("cert-request").appendVersion());
Zhiyi Zhang8f1ade32020-10-14 16:42:57 -0700141 certRequest.setContentType(ndn::tlv::ContentType_Key);
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400142 certRequest.setContent(m_keyPair.getPublicKey());
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700143 SignatureInfo signatureInfo;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500144 signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(notBefore, notAfter));
tylerliu4140fe82021-01-27 15:45:44 -0800145 m_keyChain.sign(certRequest, signingByKey(keyName).setSignatureInfo(signatureInfo));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700146
147 // generate Interest packet
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800148 Name interestName = m_caProfile.caPrefix;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700149 interestName.append("CA").append("NEW");
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500150 auto interest = std::make_shared<Interest>(interestName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700151 interest->setMustBeFresh(true);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700152 interest->setApplicationParameters(
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500153 requesttlv::encodeApplicationParameters(RequestType::NEW, m_ecdh.getSelfPubKey(), certRequest));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700154
155 // sign the Interest packet
tylerliu4140fe82021-01-27 15:45:44 -0800156 m_keyChain.sign(*interest, signingByKey(keyName));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700157 return interest;
158}
159
Davide Pesavento0dc02012021-11-23 22:55:03 -0500160std::shared_ptr<Interest>
161Request::genRevokeInterest(const Certificate& certificate)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700162{
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800163 if (!m_caProfile.caPrefix.isPrefixOf(certificate.getName())) {
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700164 return nullptr;
165 }
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500166
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700167 // generate Interest packet
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800168 Name interestName = m_caProfile.caPrefix;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700169 interestName.append("CA").append("REVOKE");
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500170 auto interest = std::make_shared<Interest>(interestName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700171 interest->setMustBeFresh(true);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700172 interest->setApplicationParameters(
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500173 requesttlv::encodeApplicationParameters(RequestType::REVOKE, m_ecdh.getSelfPubKey(), certificate));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700174 return interest;
175}
176
177std::list<std::string>
tylerliu4140fe82021-01-27 15:45:44 -0800178Request::onNewRenewRevokeResponse(const Data& reply)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700179{
Davide Pesavento0dc02012021-11-23 22:55:03 -0500180 if (!ndn::security::verifySignature(reply, *m_caProfile.cert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700181 NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
tylerliu41c11532020-10-10 16:14:45 -0700182 NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700183 }
184 processIfError(reply);
185
tylerliu4140fe82021-01-27 15:45:44 -0800186 const auto& contentTLV = reply.getContent();
Zhiyi Zhangbed854c2020-10-20 18:25:35 -0700187 std::vector<uint8_t> ecdhKey;
188 std::array<uint8_t, 32> salt;
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800189 auto challenges = requesttlv::decodeDataContent(contentTLV, ecdhKey, salt, m_requestId);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700190
Zhiyi Zhang91f86ab2020-10-05 15:36:35 -0700191 // ECDH and HKDF
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800192 auto sharedSecret = m_ecdh.deriveSecret(ecdhKey);
Zhiyi Zhangbed854c2020-10-20 18:25:35 -0700193 hkdf(sharedSecret.data(), sharedSecret.size(),
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800194 salt.data(), salt.size(), m_aesKey.data(), m_aesKey.size(),
195 m_requestId.data(), m_requestId.size());
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700196
197 // update state
Zhiyi Zhangbed854c2020-10-20 18:25:35 -0700198 return challenges;
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700199}
200
tylerliu40226332020-11-11 15:37:16 -0800201std::multimap<std::string, std::string>
tylerliu4140fe82021-01-27 15:45:44 -0800202Request::selectOrContinueChallenge(const std::string& challengeSelected)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700203{
204 auto challenge = ChallengeModule::createChallengeModule(challengeSelected);
205 if (challenge == nullptr) {
tylerliu41c11532020-10-10 16:14:45 -0700206 NDN_THROW(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700207 }
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800208 m_challengeType = challengeSelected;
209 return challenge->getRequestedParameterList(m_status, m_challengeStatus);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700210}
211
Davide Pesavento0dc02012021-11-23 22:55:03 -0500212std::shared_ptr<Interest>
tylerliu4140fe82021-01-27 15:45:44 -0800213Request::genChallengeInterest(std::multimap<std::string, std::string>&& parameters)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700214{
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400215 if (m_challengeType.empty()) {
tylerliu41c11532020-10-10 16:14:45 -0700216 NDN_THROW(std::runtime_error("The challenge has not been selected."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700217 }
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800218 auto challenge = ChallengeModule::createChallengeModule(m_challengeType);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700219 if (challenge == nullptr) {
tylerliu41c11532020-10-10 16:14:45 -0700220 NDN_THROW(std::runtime_error("The challenge selected is not supported by your current version of NDNCERT."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700221 }
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400222 auto challengeParams = challenge->genChallengeRequestTLV(m_status, m_challengeStatus, parameters);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700223
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800224 Name interestName = m_caProfile.caPrefix;
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400225 interestName.append("CA").append("CHALLENGE").append(Name::Component(m_requestId));
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500226 auto interest = std::make_shared<Interest>(interestName);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700227 interest->setMustBeFresh(true);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700228
229 // encrypt the Interest parameters
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800230 auto paramBlock = encodeBlockWithAesGcm128(ndn::tlv::ApplicationParameters, m_aesKey.data(),
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700231 challengeParams.value(), challengeParams.value_size(),
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800232 m_requestId.data(), m_requestId.size(),
233 m_encryptionIv);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700234 interest->setApplicationParameters(paramBlock);
tylerliu4140fe82021-01-27 15:45:44 -0800235 m_keyChain.sign(*interest, signingByKey(m_keyPair.getName()));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700236 return interest;
237}
238
239void
tylerliu4140fe82021-01-27 15:45:44 -0800240Request::onChallengeResponse(const Data& reply)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700241{
Davide Pesavento0dc02012021-11-23 22:55:03 -0500242 if (!ndn::security::verifySignature(reply, *m_caProfile.cert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700243 NDN_LOG_ERROR("Cannot verify replied Data packet signature.");
tylerliu41c11532020-10-10 16:14:45 -0700244 NDN_THROW(std::runtime_error("Cannot verify replied Data packet signature."));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700245 }
246 processIfError(reply);
tylerliu4140fe82021-01-27 15:45:44 -0800247 challengetlv::decodeDataContent(reply.getContent(), *this);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700248}
249
Davide Pesavento0dc02012021-11-23 22:55:03 -0500250std::shared_ptr<Interest>
tylerliu4140fe82021-01-27 15:45:44 -0800251Request::genCertFetchInterest() const
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700252{
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500253 auto interest = std::make_shared<Interest>(m_issuedCertName);
Tianyuan Yu60775552022-03-07 17:10:10 -0800254 if (!m_forwardingHint.empty()) {
255 interest->setForwardingHint({m_forwardingHint});
256 }
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700257 return interest;
258}
259
Davide Pesavento0dc02012021-11-23 22:55:03 -0500260std::shared_ptr<Certificate>
tylerliu4140fe82021-01-27 15:45:44 -0800261Request::onCertFetchResponse(const Data& reply)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700262{
263 try {
Davide Pesavento0dc02012021-11-23 22:55:03 -0500264 return std::make_shared<Certificate>(reply);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700265 }
Davide Pesavento0dc02012021-11-23 22:55:03 -0500266 catch (const std::exception&) {
Davide Pesavento64d5c8f2022-03-07 22:06:22 -0500267 NDN_LOG_ERROR("Cannot parse replied certificate");
268 NDN_THROW(std::runtime_error("Cannot parse replied certificate"));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700269 }
270}
271
272void
tylerliu4140fe82021-01-27 15:45:44 -0800273Request::processIfError(const Data& data)
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700274{
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800275 auto errorInfo = errortlv::decodefromDataContent(data.getContent());
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700276 if (std::get<0>(errorInfo) == ErrorCode::NO_ERROR) {
277 return;
278 }
Zhiyi Zhang1a222692020-10-16 11:35:49 -0700279 NDN_LOG_ERROR("Error info replied from the CA with Error code: " << std::get<0>(errorInfo) <<
280 " and Error Info: " << std::get<1>(errorInfo));
tylerliu41c11532020-10-10 16:14:45 -0700281 NDN_THROW(std::runtime_error("Error info replied from the CA with Error code: " +
Zhiyi Zhang1a222692020-10-16 11:35:49 -0700282 boost::lexical_cast<std::string>(std::get<0>(errorInfo)) +
283 " and Error Info: " + std::get<1>(errorInfo)));
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700284}
285
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400286} // namespace ndncert::requester