blob: 007352114cb581bb74570733e64ce797574ff5ae [file] [log] [blame]
Zhiyi Zhang08e0e982017-03-01 10:10:42 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
swa77020643ac2020-03-26 02:24:45 -07002/**
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -07003 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhang08e0e982017-03-01 10:10:42 -08004 *
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
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080021#include "challenge-module.hpp"
Suyong Won19fba4d2020-05-09 13:39:46 -070022#include "protocol-detail/info.hpp"
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070023#include "client-module.hpp"
Zhiyi Zhangb6fab0f2017-09-21 16:26:27 -070024#include <iostream>
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080025#include <string>
Davide Pesaventob48bbda2020-07-27 19:41:37 -040026
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -070027#include <boost/asio.hpp>
Davide Pesaventob48bbda2020-07-27 19:41:37 -040028#include <boost/program_options/options_description.hpp>
29#include <boost/program_options/parsers.hpp>
30#include <boost/program_options/variables_map.hpp>
31
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080032#include <ndn-cxx/security/verification-helpers.hpp>
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080033
34namespace ndn {
35namespace ndncert {
36
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070037static void startApplication();
38
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080039int nStep;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070040Face face;
tylerliu182bc532020-09-25 01:54:45 -070041security::v2::KeyChain keyChain;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070042std::string challengeType;
Zhiyi Zhang36706832019-07-04 21:33:03 -070043int validityPeriod = -1;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070044ClientModule client(keyChain);
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080045
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070046static std::list<std::string>
47captureParams(const JsonSection& requirement)
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080048{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070049 std::list<std::string> results;
Zhiyi Zhang547c8512019-06-18 23:46:14 -070050 for (const auto& item : requirement) {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070051 std::cerr << item.second.get<std::string>("") << std::endl;
52 std::cerr << "Please provide the argument: " << item.first << " : " << std::endl;
53 std::string tempParam;
54 getline(std::cin, tempParam);
55 results.push_back(tempParam);
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080056 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070057 std::cerr << "Got it. This is what you've provided:" << std::endl;
58 auto it1 = results.begin();
59 auto it2 = requirement.begin();
60 for (; it1 != results.end() && it2 != requirement.end(); it1++, it2++) {
61 std::cerr << it2->first << " : " << *it1 << std::endl;
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080062 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070063 return results;
64}
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080065
Zhiyi Zhang547c8512019-06-18 23:46:14 -070066static std::list<std::string>
67captureParams(const std::vector<std::string>& requirement)
68{
69 std::list<std::string> results;
70 for (const auto& item : requirement) {
71 std::cerr << "Please provide the argument: " << item << " : " << std::endl;
72 std::string tempParam;
73 getline(std::cin, tempParam);
74 results.push_back(tempParam);
75 }
76 std::cerr << "Got it. This is what you've provided:" << std::endl;
77 auto it1 = results.begin();
78 auto it2 = requirement.begin();
79 for (; it1 != results.end() && it2 != requirement.end(); it1++, it2++) {
80 std::cerr << *it2 << " : " << *it1 << std::endl;
81 }
82 return results;
83}
84
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070085static void
Zhiyi Zhang36706832019-07-04 21:33:03 -070086captureValidityPeriod()
87{
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -070088 if (validityPeriod > 0) {
89 return;
90 }
91 std::cerr << "Step " << nStep++
92 << ": Please type in your expected validity period of your certificate."
93 << " Type the number of hours (168 for week, 730 for month, 8760 for year)."
94 << " The CA may reject your application if your expected period is too long." << std::endl;
95 std::string periodStr = "";
96 getline(std::cin, periodStr);
97 try {
98 validityPeriod = std::stoi(periodStr);
99 }
100 catch (const std::exception& e) {
101 validityPeriod = -1;
Zhiyi Zhang36706832019-07-04 21:33:03 -0700102 }
103}
104
105static void
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700106onNackCb()
107{
108 std::cerr << "Got NACK\n";
109}
110
111static void
112timeoutCb()
113{
114 std::cerr << "Interest sent time out\n";
115}
116
117static void
swa770cf1d8f72020-04-21 23:12:39 -0700118certFetchCb(const Data& reply)
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700119{
swa770cf1d8f72020-04-21 23:12:39 -0700120 client.onCertFetchResponse(reply);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700121 std::cerr << "Step " << nStep++
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700122 << ": DONE! Certificate has already been installed to local keychain\n"
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -0700123 << "Certificate Name: " << reply.getName().toUri() << std::endl;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700124}
125
126static void
127challengeCb(const Data& reply)
128{
129 client.onChallengeResponse(reply);
130 if (client.getApplicationStatus() == STATUS_SUCCESS) {
131 std::cerr << "DONE! Certificate has already been issued \n";
swa770cf1d8f72020-04-21 23:12:39 -0700132 face.expressInterest(*client.generateCertFetchInterest(), bind(&certFetchCb, _2),
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700133 bind(&onNackCb), bind(&timeoutCb));
Zhiyi Zhang4d89fe02017-04-28 18:51:51 -0700134 return;
135 }
136
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700137 auto challenge = ChallengeModule::createChallengeModule(challengeType);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700138 auto requirement = challenge->getRequirementForChallenge(client.getApplicationStatus(),
139 client.getChallengeStatus());
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700140 if (requirement.size() > 0) {
Zhiyi Zhang916ba2d2018-02-01 18:16:27 -0800141 std::cerr << "Step " << nStep++ << ": Please satisfy following instruction(s)\n";
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700142 std::string redo = "";
143 std::list<std::string> capturedParams;
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700144 capturedParams = captureParams(requirement);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700145 auto it1 = capturedParams.begin();
146 auto it2 = requirement.begin();
147 for (; it1 != capturedParams.end() && it2 != requirement.end(); it1++, it2++) {
148 it2->second.put("", *it1);
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800149 }
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800150 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700151 face.expressInterest(*client.generateChallengeInterest(challenge->genChallengeRequestTLV(client.getApplicationStatus(),
Zhiyi Zhang36706832019-07-04 21:33:03 -0700152 client.getChallengeStatus(),
153 requirement)),
154 bind(&challengeCb, _2), bind(&onNackCb), bind(&timeoutCb));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700155}
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800156
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700157static void
158newCb(const Data& reply)
159{
Zhiyi Zhang36706832019-07-04 21:33:03 -0700160 int challengeIndex = 0;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700161 auto challengeList = client.onNewResponse(reply);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700162 if (challengeList.size() < 1) {
163 std::cerr << "There is no available challenge provided by the CA. Exit" << std::endl;
164 return;
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800165 }
Zhiyi Zhang36706832019-07-04 21:33:03 -0700166 else if (challengeList.size() > 1) {
167 int count = 0;
168 std::string choice = "";
169 std::cerr << "Step " << nStep++ << ": Please type in the challenge index that you want to perform\n";
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700170 count = 0;
171 for (auto item : challengeList) {
172 std::cerr << "\t" << count++ << " : "<< item << std::endl;
173 }
174 getline(std::cin, choice);
175 try {
176 challengeIndex = std::stoi(choice);
177 }
178 catch (const std::exception& e) {
179 challengeIndex = -1;
180 }
181 if (challengeIndex < 0 || challengeIndex >= count) {
182 std::cerr << "Your input index is out of range. Exit." << std::endl;
183 return;
184 }
Zhiyi Zhang36706832019-07-04 21:33:03 -0700185 }
186 auto it = challengeList.begin();
187 std::advance(it, challengeIndex);
188 unique_ptr<ChallengeModule> challenge = ChallengeModule::createChallengeModule(*it);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700189 if (challenge != nullptr) {
Zhiyi Zhang36706832019-07-04 21:33:03 -0700190 challengeType = *it;
191 std::cerr << "The challenge has been selected: " << challengeType << std::endl;
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800192 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700193 else {
Zhiyi Zhang36706832019-07-04 21:33:03 -0700194 std::cerr << "Error. Cannot load selected Challenge Module. Exit." << std::endl;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700195 return;
196 }
197 auto requirement = challenge->getRequirementForChallenge(client.getApplicationStatus(),
198 client.getChallengeStatus());
199 if (requirement.size() > 0) {
200 std::cerr << "Step " << nStep++ << ": Please satisfy following instruction(s)\n";
201 std::string redo = "";
202 std::list<std::string> capturedParams;
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700203 capturedParams = captureParams(requirement);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700204 auto it1 = capturedParams.begin();
205 auto it2 = requirement.begin();
206 for (; it1 != capturedParams.end() && it2 != requirement.end(); it1++, it2++) {
207 it2->second.put("", *it1);
208 }
209 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700210 face.expressInterest(*client.generateChallengeInterest(challenge->genChallengeRequestTLV(client.getApplicationStatus(),
Zhiyi Zhang36706832019-07-04 21:33:03 -0700211 client.getChallengeStatus(),
212 requirement)),
213 bind(&challengeCb, _2), bind(&onNackCb), bind(&timeoutCb));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700214}
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800215
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700216static void
Suyong Won19fba4d2020-05-09 13:39:46 -0700217InfoCb(const Data& reply)
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700218{
Suyong Won19fba4d2020-05-09 13:39:46 -0700219 const Block& contentBlock = reply.getContent();
220
221 if (!client.verifyInfoResponse(reply)) {
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700222 std::cerr << "The fetched CA information cannot be trusted because its integrity is broken" << std::endl;
223 return;
224 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700225 auto caItem = INFO::decodeClientConfigFromContent(contentBlock);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700226
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700227 std::cerr << "Will use a new trust anchor, please double check the identity info: \n"
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -0700228 << "This trust anchor information is signed by " << reply.getSignature().getKeyLocator()
Davide Pesaventob48bbda2020-07-27 19:41:37 -0400229 << std::endl
230 << "The certificate is " << caItem.m_anchor << std::endl
231 << "Do you trust the information? Type in YES or NO" << std::endl;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700232
233 std::string answer;
234 getline(std::cin, answer);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700235 boost::algorithm::to_lower(answer);
236 if (answer == "yes") {
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700237 std::cerr << "You answered YES: new CA will be used" << std::endl;
Suyong Won19fba4d2020-05-09 13:39:46 -0700238 client.addCaFromInfoResponse(reply);
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700239 // client.getClientConf().save(std::string(SYSCONFDIR) + "/ndncert/client.conf");
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700240 startApplication();
241 }
242 else {
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700243 std::cerr << "You answered NO: new CA will not be used" << std::endl;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700244 return;
245 }
246}
247
248static void
249probeCb(const Data& reply)
250{
Zhiyi Zhang781a5602019-06-26 19:05:04 -0700251 client.onProbeResponse(reply);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700252 captureValidityPeriod();
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700253 if (validityPeriod <= 0) {
254 std::cerr << "Invalid period time. Exit." << std::endl;
255 return;
256 }
Zhiyi Zhang781a5602019-06-26 19:05:04 -0700257 auto probeToken = make_shared<Data>(reply);
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700258 auto now = time::system_clock::now();
Zhiyi Zhang36706832019-07-04 21:33:03 -0700259 std::cerr << "The validity period of your certificate will be: " << validityPeriod << " hours" << std::endl;
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700260 auto interest = client.generateNewInterest(now, now + time::hours(validityPeriod), Name(), probeToken);
261 if (interest != nullptr) {
262 face.expressInterest(*interest, bind(&newCb, _2), bind(&onNackCb), bind(&timeoutCb));
263 }
264 else {
265 std::cerr << "Cannot generate the Interest for NEW step. Exit" << std::endl;
266 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700267}
268
269static void
270startApplication()
271{
272 nStep = 0;
273 auto caList = client.getClientConf().m_caItems;
274 int count = 0;
275 for (auto item : caList) {
276 std::cerr << "***************************************\n"
277 << "Index: " << count++ << "\n"
Suyong Won256c9062020-05-11 02:45:56 -0700278 << "CA prefix:" << item.m_caPrefix << "\n"
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700279 << "Introduction: " << item.m_caInfo << "\n"
280 << "***************************************\n";
281 }
282 std::vector<ClientCaItem> caVector{std::begin(caList), std::end(caList)};
283 std::cerr << "Step "
284 << nStep++ << ": Please type in the CA INDEX that you want to apply"
285 << " or type in NONE if your expected CA is not in the list\n";
286
Zhiyi Zhang36706832019-07-04 21:33:03 -0700287 std::string caIndexS, caIndexSLower;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700288 getline(std::cin, caIndexS);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700289 caIndexSLower = caIndexS;
290 boost::algorithm::to_lower(caIndexSLower);
291 if (caIndexSLower == "none") {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700292 std::cerr << "Step " << nStep << ": Please type in the CA Name\n";
Zhiyi Zhangcaab5462019-10-18 13:41:02 -0700293 std::string expectedCAName;
294 getline(std::cin, expectedCAName);
swa77020643ac2020-03-26 02:24:45 -0700295 face.expressInterest(*client.generateInfoInterest(Name(expectedCAName)),
Suyong Won19fba4d2020-05-09 13:39:46 -0700296 bind(&InfoCb, _2), bind(&onNackCb), bind(&timeoutCb));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700297 }
298 else {
Zhiyi Zhang36706832019-07-04 21:33:03 -0700299 int caIndex;
300 try {
301 caIndex = std::stoi(caIndexS);
302 }
303 catch (const std::exception& e) {
304 std::cerr << "Your input is neither NONE nor a valid index. Exit" << std::endl;
305 return;
306 }
307 if (caIndex < 0 || caIndex >= count) {
308 std::cerr << "Your input is not an existing index. Exit" << std::endl;
309 return;
310 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700311 auto targetCaItem = caVector[caIndex];
312
313 if (targetCaItem.m_probe != "") {
Zhiyi Zhang547c8512019-06-18 23:46:14 -0700314 std::cerr << "Step " << nStep++ << ": Please provide information for name assignment" << std::endl;
315 std::vector<std::string> probeFields = ClientModule::parseProbeComponents(targetCaItem.m_probe);
316 std::string redo = "";
317 std::list<std::string> capturedParams;
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700318 capturedParams = captureParams(probeFields);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700319 std::string probeInfo;
Zhiyi Zhang547c8512019-06-18 23:46:14 -0700320 for (const auto& item : capturedParams) {
321 probeInfo += item;
322 probeInfo += ":";
323 }
324 probeInfo = probeInfo.substr(0, probeInfo.size() - 1);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700325 face.expressInterest(*client.generateProbeInterest(targetCaItem, probeInfo),
Zhiyi Zhang36706832019-07-04 21:33:03 -0700326 bind(&probeCb, _2), bind(&onNackCb), bind(&timeoutCb));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700327 }
328 else {
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700329 std::cerr << "Step " << nStep++ << ": Please type in the full identity name you want to get (with CA prefix)\n";
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700330 std::string identityNameStr;
331 getline(std::cin, identityNameStr);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700332 captureValidityPeriod();
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700333 if (validityPeriod <= 0) {
334 std::cerr << "Invalid period time. Exit." << std::endl;
335 return;
336 }
337 Name idName(identityNameStr);
Zhiyi Zhang36706832019-07-04 21:33:03 -0700338 std::cerr << "The validity period of your certificate will be: " << validityPeriod << " hours" << std::endl;
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700339 auto now = time::system_clock::now();
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700340 auto interest = client.generateNewInterest(now, now + time::hours(validityPeriod), idName);
341 if (interest != nullptr) {
342 face.expressInterest(*interest, bind(&newCb, _2), bind(&onNackCb), bind(&timeoutCb));
343 }
344 else {
345 std::cerr << "Cannot generate the Interest for NEW step. Exit" << std::endl;
346 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700347 }
348 }
349}
350
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700351static void
352handleSignal(const boost::system::error_code& error, int signalNum)
353{
354 if (error) {
355 return;
356 }
357 const char* signalName = ::strsignal(signalNum);
358 std::cerr << "Exiting on signal ";
359 if (signalName == nullptr) {
360 std::cerr << signalNum;
361 }
362 else {
363 std::cerr << signalName;
364 }
365 std::cerr << std::endl;
366 client.endSession();
367 face.getIoService().stop();
368}
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800369
370int
371main(int argc, char* argv[])
372{
Zhiyi Zhangad9e04f2020-03-27 12:04:31 -0700373 boost::asio::signal_set terminateSignals(face.getIoService());
374 terminateSignals.add(SIGINT);
375 terminateSignals.add(SIGTERM);
376 terminateSignals.async_wait(handleSignal);
377
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800378 namespace po = boost::program_options;
379 std::string configFilePath = std::string(SYSCONFDIR) + "/ndncert/client.conf";
Zhiyi Zhang36706832019-07-04 21:33:03 -0700380 po::options_description description("General Usage\n ndncert-client [-h] [-c] [-v]\n");
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800381 description.add_options()
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700382 ("help,h", "produce help message")
Davide Pesaventob48bbda2020-07-27 19:41:37 -0400383 ("config-file,c", po::value<std::string>(&configFilePath), "configuration file name")
384 ("validity-period,v", po::value<int>(&validityPeriod)->default_value(-1),
385 "desired validity period (hours) of the certificate being requested");
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800386 po::positional_options_description p;
387
388 po::variables_map vm;
389 try {
390 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
391 po::notify(vm);
392 }
393 catch (const std::exception& e) {
394 std::cerr << "ERROR: " << e.what() << std::endl;
395 return 1;
396 }
397 if (vm.count("help") != 0) {
398 std::cerr << description << std::endl;
399 return 0;
400 }
Zhiyi Zhangd8993b92019-07-04 21:58:10 -0700401 try {
402 client.getClientConf().load(configFilePath);
403 }
404 catch (const std::exception& e) {
405 std::cerr << "Cannot load the configuration file: " << e.what() << std::endl;
406 return 1;
407 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700408 startApplication();
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800409 face.processEvents();
410 return 0;
411}
412
413} // namespace ndncert
414} // namespace ndn
415
Zhiyi Zhang916ba2d2018-02-01 18:16:27 -0800416int main(int argc, char* argv[])
Zhiyi Zhang08e0e982017-03-01 10:10:42 -0800417{
418 return ndn::ndncert::main(argc, argv);
419}