Fix build against current ndn-cxx
Change-Id: I9f2e06204ee190d507c76aac7ead09ad8e4d5009
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index e3f3daa..cd28b94 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -27,6 +27,7 @@
#include "detail/info-encoder.hpp"
#include "detail/request-encoder.hpp"
#include "detail/probe-encoder.hpp"
+
#include <ndn-cxx/metadata-object.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
#include <ndn-cxx/security/verification-helpers.hpp>
@@ -77,36 +78,36 @@
auto prefixId = m_face.registerPrefix(
prefix,
- [&](const Name& name)
- {
+ [&] (const Name& name) {
// register INFO RDR metadata prefix
name::Component metaDataComp(32, reinterpret_cast<const uint8_t*>("metadata"), std::strlen("metadata"));
auto filterId = m_face.setInterestFilter(Name(name).append("INFO").append(metaDataComp),
- bind(&CaModule::onCaProfileDiscovery, this, _2));
+ [this] (auto&&, const auto& i) { onCaProfileDiscovery(i); });
m_interestFilterHandles.push_back(filterId);
// register PROBE prefix
filterId = m_face.setInterestFilter(Name(name).append("PROBE"),
- bind(&CaModule::onProbe, this, _2));
+ [this] (auto&&, const auto& i) { onProbe(i); });
m_interestFilterHandles.push_back(filterId);
// register NEW prefix
filterId = m_face.setInterestFilter(Name(name).append("NEW"),
- bind(&CaModule::onNewRenewRevoke, this, _2, RequestType::NEW));
+ [this] (auto&&, const auto& i) { onNewRenewRevoke(i, RequestType::NEW); });
m_interestFilterHandles.push_back(filterId);
// register SELECT prefix
filterId = m_face.setInterestFilter(Name(name).append("CHALLENGE"),
- bind(&CaModule::onChallenge, this, _2));
+ [this] (auto&&, const auto& i) { onChallenge(i); });
m_interestFilterHandles.push_back(filterId);
// register REVOKE prefix
filterId = m_face.setInterestFilter(Name(name).append("REVOKE"),
- bind(&CaModule::onNewRenewRevoke, this, _2, RequestType::REVOKE));
+ [this] (auto&&, const auto& i) { onNewRenewRevoke(i, RequestType::REVOKE); });
m_interestFilterHandles.push_back(filterId);
+
NDN_LOG_TRACE("Prefix " << name << " got registered");
},
- bind(&CaModule::onRegisterFailed, this, _2));
+ [this] (auto&&, const auto& reason) { onRegisterFailed(reason); });
m_registeredPrefixHandles.push_back(prefixId);
}
diff --git a/src/challenge/challenge-possession.cpp b/src/challenge/challenge-possession.cpp
index 73a0c29..ef93d25 100644
--- a/src/challenge/challenge-possession.cpp
+++ b/src/challenge/challenge-possession.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -18,12 +18,15 @@
*/
#include "challenge-possession.hpp"
-#include <ndn-cxx/security/verification-helpers.hpp>
+
#include <ndn-cxx/security/signing-helpers.hpp>
#include <ndn-cxx/security/transform/public-key.hpp>
+#include <ndn-cxx/security/verification-helpers.hpp>
#include <ndn-cxx/util/io.hpp>
#include <ndn-cxx/util/random.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
namespace ndn {
namespace ndncert {
@@ -53,9 +56,9 @@
try {
boost::property_tree::read_json(m_configFile, config);
}
- catch (const boost::property_tree::info_parser_error& error) {
- NDN_THROW(std::runtime_error("Failed to parse configuration file " + m_configFile +
- " " + error.message() + " line " + std::to_string(error.line())));
+ catch (const boost::property_tree::file_parser_error& error) {
+ NDN_THROW(std::runtime_error("Failed to parse configuration file " + m_configFile + ": " +
+ error.message() + " on line " + std::to_string(error.line())));
}
if (config.begin() == config.end()) {
@@ -96,7 +99,8 @@
}
catch (const std::exception& e) {
NDN_LOG_ERROR("Cannot load challenge parameter: credential " << e.what());
- return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Cannot challenge credential: credential." + std::string(e.what()));
+ return returnWithError(request, ErrorCode::INVALID_PARAMETER,
+ "Cannot challenge credential: credential."s + e.what());
}
}
else if (readString(elements[i]) == PARAMETER_KEY_PROOF) {
@@ -114,7 +118,7 @@
if (credential.hasContent() && signatureLen == 0) {
Name signingKeyName = credential.getSignatureInfo().getKeyLocator().getName();
security::transform::PublicKey key;
- const auto &pubKeyBuffer = credential.getPublicKey();
+ const auto& pubKeyBuffer = credential.getPublicKey();
key.loadPkcs8(pubKeyBuffer.data(), pubKeyBuffer.size());
for (auto anchor : m_trustAnchors) {
if (anchor.getKeyName() == signingKeyName) {
@@ -123,8 +127,9 @@
}
}
}
- } else {
- return returnWithError(request, ErrorCode::BAD_INTEREST_FORMAT, "Cannot find certificate");
+ }
+ else {
+ return returnWithError(request, ErrorCode::BAD_INTEREST_FORMAT, "Cannot find certificate");
}
if (!checkOK) {
return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Certificate cannot be verified");
@@ -140,11 +145,12 @@
NDN_LOG_TRACE("Secret for request " << toHex(request.requestId.data(), request.requestId.size())
<< " : " << toHex(secretCode.data(), 16));
return returnWithNewChallengeStatus(request, NEED_PROOF, std::move(secretJson), m_maxAttemptTimes, m_secretLifetime);
- } else if (request.challengeState && request.challengeState->challengeStatus == NEED_PROOF) {
+ }
+ else if (request.challengeState && request.challengeState->challengeStatus == NEED_PROOF) {
NDN_LOG_TRACE("Challenge Interest (proof) arrives. Check the proof");
//check the format and load credential
if (credential.hasContent() || signatureLen == 0) {
- return returnWithError(request, ErrorCode::BAD_INTEREST_FORMAT, "Cannot find certificate");
+ return returnWithError(request, ErrorCode::BAD_INTEREST_FORMAT, "Cannot find certificate");
}
credential = security::Certificate(Block(fromHex(request.challengeState->secrets.get(PARAMETER_KEY_CREDENTIAL_CERT, ""))));
auto secretCode = *fromHex(request.challengeState->secrets.get(PARAMETER_KEY_NONCE, ""));
@@ -153,11 +159,11 @@
security::transform::PublicKey key;
const auto& pubKeyBuffer = credential.getPublicKey();
key.loadPkcs8(pubKeyBuffer.data(), pubKeyBuffer.size());
- if (security::verifySignature(secretCode.data(), secretCode.size(), signature, signatureLen, key)) {
+ if (security::verifySignature({{secretCode.data(), secretCode.size()}}, signature, signatureLen, key)) {
return returnWithSuccess(request);
}
return returnWithError(request, ErrorCode::INVALID_PARAMETER,
- "Cannot verify the proof of private key against credential.");
+ "Cannot verify the proof of private key against credential.");
}
NDN_LOG_TRACE("Proof of possession: bad state");
return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Fail to recognize the request.");
@@ -171,12 +177,13 @@
if (status == Status::BEFORE_CHALLENGE) {
result.emplace(PARAMETER_KEY_CREDENTIAL_CERT, "Please provide the certificate issued by a trusted CA.");
return result;
- } else if (status == Status::CHALLENGE && challengeStatus == NEED_PROOF) {
+ }
+ else if (status == Status::CHALLENGE && challengeStatus == NEED_PROOF) {
result.emplace(PARAMETER_KEY_PROOF, "Please sign a Data packet with request ID as the content.");
- } else {
+ }
+ else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
-
return result;
}
@@ -195,29 +202,33 @@
request.push_back(makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_CREDENTIAL_CERT));
Block valueBlock(tlv::ParameterValue);
auto& certTlvStr = std::get<1>(item);
- valueBlock.push_back(Block((uint8_t*)certTlvStr.c_str(), certTlvStr.size()));
+ valueBlock.push_back(Block(reinterpret_cast<const uint8_t*>(certTlvStr.data()), certTlvStr.size()));
request.push_back(valueBlock);
}
else {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
}
- } else if (status == Status::CHALLENGE && challengeStatus == NEED_PROOF){
+ }
+ else if (status == Status::CHALLENGE && challengeStatus == NEED_PROOF){
if (params.size() != 1) {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
- for (const auto &item : params) {
+ for (const auto& item : params) {
if (std::get<0>(item) == PARAMETER_KEY_PROOF) {
request.push_back(makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_PROOF));
- auto &sigTlvStr = std::get<1>(item);
- Block valueBlock = makeBinaryBlock(tlv::ParameterValue, (uint8_t *) sigTlvStr.c_str(),
+ auto& sigTlvStr = std::get<1>(item);
+ Block valueBlock = makeBinaryBlock(tlv::ParameterValue,
+ reinterpret_cast<const uint8_t*>(sigTlvStr.data()),
sigTlvStr.size());
request.push_back(valueBlock);
- } else {
+ }
+ else {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
}
- } else {
+ }
+ else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
}
request.encode();
@@ -229,20 +240,20 @@
KeyChain& keyChain, const Name& issuedCertName,
const std::array<uint8_t, 16>& nonce)
{
- auto& pib = keyChain.getPib();
- auto id = pib.getIdentity(security::extractIdentityFromCertName(issuedCertName));
- auto issuedCert = id.getKey(security::extractKeyNameFromCertName(issuedCertName)).getCertificate(issuedCertName);
+ auto keyName = security::extractKeyNameFromCertName(issuedCertName);
+ auto id = keyChain.getPib().getIdentity(security::extractIdentityFromCertName(issuedCertName));
+ auto issuedCert = id.getKey(keyName).getCertificate(issuedCertName);
auto issuedCertTlv = issuedCert.wireEncode();
- auto signatureTlv = keyChain.sign(nonce.data(), nonce.size(), security::signingByCertificate(issuedCertName));
+ auto signature = keyChain.getTpm().sign({{nonce.data(), nonce.size()}}, keyName, DigestAlgorithm::SHA256);
+
for (auto& item : params) {
- if (std::get<0>(item) == PARAMETER_KEY_CREDENTIAL_CERT) {
- std::get<1>(item) = std::string((char*)issuedCertTlv.wire(), issuedCertTlv.size());
+ if (item.first == PARAMETER_KEY_CREDENTIAL_CERT) {
+ item.second = std::string(reinterpret_cast<const char*>(issuedCertTlv.wire()), issuedCertTlv.size());
}
- else if (std::get<0>(item) == PARAMETER_KEY_PROOF) {
- std::get<1>(item) = std::string((char*)signatureTlv.value(), signatureTlv.value_size());
+ else if (item.first == PARAMETER_KEY_PROOF) {
+ item.second = std::string(signature->get<char>(), signature->size());
}
}
- return;
}
} // namespace ndncert
diff --git a/src/detail/ca-configuration.cpp b/src/detail/ca-configuration.cpp
index 7d27bfb..813c428 100644
--- a/src/detail/ca-configuration.cpp
+++ b/src/detail/ca-configuration.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,8 +19,11 @@
*/
#include "detail/ca-configuration.hpp"
+
#include <ndn-cxx/util/io.hpp>
+
#include <boost/filesystem.hpp>
+#include <boost/property_tree/json_parser.hpp>
namespace ndn {
namespace ndncert {
@@ -39,7 +42,7 @@
if (configJson.begin() == configJson.end()) {
NDN_THROW(std::runtime_error("No JSON configuration found in file: " + fileName));
}
- caProfile = CaProfile::fromJson(configJson);
+ caProfile = CaProfile::fromJson(configJson);
if (caProfile.supportedChallenges.size() == 0) {
NDN_THROW(std::runtime_error("At least one challenge should be specified."));
}
diff --git a/src/detail/ca-request-state.cpp b/src/detail/ca-request-state.cpp
index 53783d4..b8a6b27 100644
--- a/src/detail/ca-request-state.cpp
+++ b/src/detail/ca-request-state.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,15 +19,17 @@
*/
#include "detail/ca-request-state.hpp"
+
#include <ndn-cxx/util/indented-stream.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
namespace ndn {
namespace ndncert {
std::string statusToString(Status status)
{
- switch (status)
- {
+ switch (status) {
case Status::BEFORE_CHALLENGE:
return "Before challenge";
case Status::CHALLENGE:
@@ -58,11 +60,11 @@
const time::system_clock::TimePoint& challengeTp,
size_t remainingTries, time::seconds remainingTime,
JsonSection&& challengeSecrets)
- : challengeStatus(challengeStatus)
- , timestamp(challengeTp)
- , remainingTries(remainingTries)
- , remainingTime(remainingTime)
- , secrets(std::move(challengeSecrets))
+ : challengeStatus(challengeStatus)
+ , timestamp(challengeTp)
+ , remainingTries(remainingTries)
+ , remainingTime(remainingTime)
+ , secrets(std::move(challengeSecrets))
{
}
diff --git a/src/detail/ca-sqlite.cpp b/src/detail/ca-sqlite.cpp
index 1cddfed..c247501 100644
--- a/src/detail/ca-sqlite.cpp
+++ b/src/detail/ca-sqlite.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -21,10 +21,13 @@
#include "detail/ca-sqlite.hpp"
#include <sqlite3.h>
-#include <boost/filesystem.hpp>
+
#include <ndn-cxx/security/validation-policy.hpp>
#include <ndn-cxx/util/sqlite3-statement.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
namespace ndn {
namespace ndncert {
namespace ca {
@@ -186,7 +189,8 @@
statement.bind(11, request.challengeState->remainingTime.count());
}
if (statement.step() != SQLITE_DONE) {
- NDN_THROW(std::runtime_error("Request " + toHex(request.requestId.data(), request.requestId.size()) + " cannot be added to database"));
+ NDN_THROW(std::runtime_error("Request " + toHex(request.requestId.data(), request.requestId.size()) +
+ " cannot be added to database"));
}
}
diff --git a/src/detail/ndncert-common.hpp b/src/detail/ndncert-common.hpp
index 0e1b392..01fa883 100644
--- a/src/detail/ndncert-common.hpp
+++ b/src/detail/ndncert-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -37,6 +37,9 @@
#include <cstddef>
#include <cstdint>
+#include <string>
+#include <tuple>
+
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
#include <ndn-cxx/encoding/block.hpp>
@@ -48,13 +51,11 @@
#include <ndn-cxx/security/certificate.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/util/logger.hpp>
-#include <ndn-cxx/util/nonstd/optional.hpp>
-#include <tuple>
+#include <ndn-cxx/util/optional.hpp>
+
#include <boost/algorithm/string.hpp>
#include <boost/assert.hpp>
#include <boost/noncopyable.hpp>
-#include <boost/property_tree/info_parser.hpp>
-#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
namespace ndn {
@@ -93,8 +94,7 @@
} // namespace tlv
-using boost::noncopyable;
-typedef boost::property_tree::ptree JsonSection;
+using JsonSection = boost::property_tree::ptree;
// NDNCERT error code
enum class ErrorCode : uint64_t {
diff --git a/src/detail/profile-storage.cpp b/src/detail/profile-storage.cpp
index 7ae3c08..949309a 100644
--- a/src/detail/profile-storage.cpp
+++ b/src/detail/profile-storage.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,7 +19,9 @@
*/
#include "detail/profile-storage.hpp"
+
#include <boost/filesystem.hpp>
+#include <boost/property_tree/json_parser.hpp>
namespace ndn {
namespace ndncert {
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 08c88f4..fec4aa1 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,13 +19,15 @@
*/
#include "requester-request.hpp"
+
#include <ndn-cxx/security/verification-helpers.hpp>
+
#include <boost/asio.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
+
#include <iostream>
-#include <string>
namespace ndn {
namespace ndncert {
@@ -33,17 +35,20 @@
static void
selectCaProfile(std::string configFilePath);
+
static void
runProbe(CaProfile profile);
+
static void
runNew(CaProfile profile, Name identityName);
+
static void
runChallenge(const std::string& challengeType);
-size_t nStep = 1;
-Face face;
-security::KeyChain keyChain;
-shared_ptr<Request> requesterState = nullptr;
+static size_t nStep = 1;
+static Face face;
+static security::KeyChain keyChain;
+static shared_ptr<Request> requesterState;
static void
captureParams(std::multimap<std::string, std::string>& requirement)
@@ -135,8 +140,10 @@
}
if (requesterState->m_status == Status::SUCCESS) {
std::cerr << "Certificate has already been issued, downloading certificate..." << std::endl;
- face.expressInterest(*requesterState->genCertFetchInterest(), bind(&certFetchCb, _2),
- bind(&onNackCb), bind(&timeoutCb));
+ face.expressInterest(*requesterState->genCertFetchInterest(),
+ [] (const auto&, const auto& data) { certFetchCb(data); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
return;
}
runChallenge(requesterState->m_challengeType);
@@ -200,7 +207,7 @@
}
static void
-InfoCb(const Data& reply, const Name& certFullName)
+infoCb(const Data& reply, const Name& certFullName)
{
optional<CaProfile> profile;
try {
@@ -299,15 +306,15 @@
std::cerr << "You selected to be redirected to CA: " << redirectedCaName.toUri() << std::endl;
face.expressInterest(
*Request::genCaProfileDiscoveryInterest(redirectedCaName),
- [&](const Interest&, const Data& data) {
+ [&] (const auto&, const auto& data) {
auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data);
face.expressInterest(*fetchingInterest,
- bind(&InfoCb, _2, redirectedCaFullName),
- bind(&onNackCb),
- bind(&timeoutCb));
+ [=] (const auto&, const auto& data2) { infoCb(data2, redirectedCaFullName); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
},
- bind(&onNackCb),
- bind(&timeoutCb));
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
}
}
@@ -343,15 +350,15 @@
getline(std::cin, expectedCAName);
face.expressInterest(
*Request::genCaProfileDiscoveryInterest(Name(expectedCAName)),
- [&](const Interest&, const Data& data) {
+ [&] (const auto&, const auto& data) {
auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data);
face.expressInterest(*fetchingInterest,
- bind(&InfoCb, _2, Name()),
- bind(&onNackCb),
- bind(&timeoutCb));
+ [] (const auto&, const auto& data2) { infoCb(data2, {}); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
},
- bind(&onNackCb),
- bind(&timeoutCb));
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
}
else {
size_t caIndex;
@@ -406,7 +413,9 @@
<< "Step " << nStep++ << ": Please provide information for name assignment" << std::endl;
auto capturedParams = captureParams(profile.probeParameterKeys);
face.expressInterest(*Request::genProbeInterest(profile, std::move(capturedParams)),
- bind(&probeCb, _2, profile), bind(&onNackCb), bind(&timeoutCb));
+ [profile] (const auto&, const auto& data) { probeCb(data, profile); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
}
else {
std::cerr << "Invalid answer. Type in YES or NO" << std::endl;
@@ -428,7 +437,10 @@
requesterState = std::make_shared<Request>(keyChain, profile, RequestType::NEW);
auto interest = requesterState->genNewInterest(identityName, now, now + time::hours(validityPeriod));
if (interest != nullptr) {
- face.expressInterest(*interest, bind(&newCb, _2), bind(&onNackCb), bind(&timeoutCb));
+ face.expressInterest(*interest,
+ [] (const auto&, const auto& data) { newCb(data); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
}
else {
std::cerr << "Cannot generate the Interest for NEW step. Exit" << std::endl;
@@ -443,8 +455,8 @@
requirement = requesterState->selectOrContinueChallenge(challengeType);
}
catch (const std::exception& e) {
- std::cerr << "Error. Cannot successfully load the Challenge Module with error: " << std::string(e.what())
- << "Exit." << std::endl;
+ std::cerr << "Error. Cannot successfully load the Challenge Module with error: " << e.what()
+ << "\nExit." << std::endl;
exit(1);
}
if (requirement.size() > 0) {
@@ -454,7 +466,9 @@
captureParams(requirement);
}
face.expressInterest(*requesterState->genChallengeInterest(std::move(requirement)),
- bind(&challengeCb, _2), bind(&onNackCb), bind(&timeoutCb));
+ [] (const auto&, const auto& data) { challengeCb(data); },
+ [] (auto&&...) { onNackCb(); },
+ [] (auto&&...) { timeoutCb(); });
}
static void
@@ -479,7 +493,7 @@
exit(1);
}
-int
+static int
main(int argc, char* argv[])
{
boost::asio::signal_set terminateSignals(face.getIoService());
@@ -489,8 +503,11 @@
namespace po = boost::program_options;
std::string configFilePath = std::string(NDNCERT_SYSCONFDIR) + "/ndncert/client.conf";
- po::options_description description("General Usage\n ndncert-client [-h] [-c] [-v]\n");
- description.add_options()("help,h", "produce help message")("config-file,c", po::value<std::string>(&configFilePath), "configuration file name");
+ po::options_description description("Usage: ndncert-client [-h] [-c FILE]\n");
+ description.add_options()
+ ("help,h", "produce help message")
+ ("config-file,c", po::value<std::string>(&configFilePath), "configuration file name")
+ ;
po::positional_options_description p;
po::variables_map vm;
@@ -502,10 +519,12 @@
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
}
+
if (vm.count("help") != 0) {
std::cerr << description << std::endl;
return 0;
}
+
selectCaProfile(configFilePath);
face.processEvents();
return 0;