Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2019, Regents of the University of California. |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 4 | * |
| 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 | |
| 21 | #include "client-module.hpp" |
| 22 | #include "challenge-module.hpp" |
Zhiyi Zhang | b6fab0f | 2017-09-21 16:26:27 -0700 | [diff] [blame] | 23 | #include <iostream> |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 24 | #include <string> |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 25 | #include <algorithm> |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 26 | #include <boost/program_options/options_description.hpp> |
| 27 | #include <boost/program_options/variables_map.hpp> |
| 28 | #include <boost/program_options/parsers.hpp> |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 29 | #include <ndn-cxx/security/verification-helpers.hpp> |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 30 | |
| 31 | namespace ndn { |
| 32 | namespace ndncert { |
| 33 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 34 | static void startApplication(); |
| 35 | |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 36 | int nStep; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 37 | Face face; |
| 38 | security::v2::KeyChain keyChain; |
| 39 | std::string challengeType; |
| 40 | ClientModule client(keyChain); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 41 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 42 | static std::list<std::string> |
| 43 | captureParams(const JsonSection& requirement) |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 44 | { |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 45 | std::list<std::string> results; |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 46 | for (const auto& item : requirement) { |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 47 | std::cerr << item.second.get<std::string>("") << std::endl; |
| 48 | std::cerr << "Please provide the argument: " << item.first << " : " << std::endl; |
| 49 | std::string tempParam; |
| 50 | getline(std::cin, tempParam); |
| 51 | results.push_back(tempParam); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 52 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 53 | std::cerr << "Got it. This is what you've provided:" << std::endl; |
| 54 | auto it1 = results.begin(); |
| 55 | auto it2 = requirement.begin(); |
| 56 | for (; it1 != results.end() && it2 != requirement.end(); it1++, it2++) { |
| 57 | std::cerr << it2->first << " : " << *it1 << std::endl; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 58 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 59 | return results; |
| 60 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 61 | |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 62 | static std::list<std::string> |
| 63 | captureParams(const std::vector<std::string>& requirement) |
| 64 | { |
| 65 | std::list<std::string> results; |
| 66 | for (const auto& item : requirement) { |
| 67 | std::cerr << "Please provide the argument: " << item << " : " << std::endl; |
| 68 | std::string tempParam; |
| 69 | getline(std::cin, tempParam); |
| 70 | results.push_back(tempParam); |
| 71 | } |
| 72 | std::cerr << "Got it. This is what you've provided:" << std::endl; |
| 73 | auto it1 = results.begin(); |
| 74 | auto it2 = requirement.begin(); |
| 75 | for (; it1 != results.end() && it2 != requirement.end(); it1++, it2++) { |
| 76 | std::cerr << *it2 << " : " << *it1 << std::endl; |
| 77 | } |
| 78 | return results; |
| 79 | } |
| 80 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 81 | static void |
| 82 | onNackCb() |
| 83 | { |
| 84 | std::cerr << "Got NACK\n"; |
| 85 | } |
| 86 | |
| 87 | static void |
| 88 | timeoutCb() |
| 89 | { |
| 90 | std::cerr << "Interest sent time out\n"; |
| 91 | } |
| 92 | |
| 93 | static void |
| 94 | downloadCb(const Data& reply) |
| 95 | { |
| 96 | client.onDownloadResponse(reply); |
| 97 | std::cerr << "Step " << nStep++ |
| 98 | << ": DONE! Certificate has already been installed to local keychain\n"; |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | challengeCb(const Data& reply) |
| 104 | { |
| 105 | client.onChallengeResponse(reply); |
| 106 | if (client.getApplicationStatus() == STATUS_SUCCESS) { |
| 107 | std::cerr << "DONE! Certificate has already been issued \n"; |
| 108 | face.expressInterest(*client.generateDownloadInterest(), bind(&downloadCb, _2), |
| 109 | bind(&onNackCb), bind(&timeoutCb)); |
Zhiyi Zhang | 4d89fe0 | 2017-04-28 18:51:51 -0700 | [diff] [blame] | 110 | return; |
| 111 | } |
| 112 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 113 | auto challenge = ChallengeModule::createChallengeModule(challengeType); |
| 114 | auto requirement = challenge->getRequirementForChallenge(client.getApplicationStatus(), client.getChallengeStatus()); |
| 115 | if (requirement.size() > 0) { |
Zhiyi Zhang | 916ba2d | 2018-02-01 18:16:27 -0800 | [diff] [blame] | 116 | std::cerr << "Step " << nStep++ << ": Please satisfy following instruction(s)\n"; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 117 | std::string redo = ""; |
| 118 | std::list<std::string> capturedParams; |
| 119 | do { |
| 120 | capturedParams = captureParams(requirement); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 121 | std::cerr << "If everything is right, please type in OK; otherwise, type in REDO" << std::endl; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 122 | getline(std::cin, redo); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 123 | std::transform(redo.begin(), redo.end(), redo.begin(), ::toupper); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 124 | } while (redo == "REDO"); |
| 125 | auto it1 = capturedParams.begin(); |
| 126 | auto it2 = requirement.begin(); |
| 127 | for (; it1 != capturedParams.end() && it2 != requirement.end(); it1++, it2++) { |
| 128 | it2->second.put("", *it1); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 129 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 130 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 131 | face.expressInterest(*client.generateChallengeInterest( |
| 132 | challenge->genChallengeRequestJson( |
| 133 | client.getApplicationStatus(), |
| 134 | client.getChallengeStatus(), |
| 135 | requirement)), |
| 136 | bind(&challengeCb, _2), |
| 137 | bind(&onNackCb), |
| 138 | bind(&timeoutCb)); |
| 139 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 140 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 141 | static void |
| 142 | newCb(const Data& reply) |
| 143 | { |
| 144 | auto challengeList = client.onNewResponse(reply); |
| 145 | std::cerr << "Step " << nStep++ << ": Please type in the challenge ID from the following challenges\n"; |
| 146 | for (auto item : challengeList) { |
| 147 | std::cerr << "\t" << item << std::endl; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 148 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 149 | std::string choice; |
| 150 | getline(std::cin, choice); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 151 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 152 | auto challenge = ChallengeModule::createChallengeModule(choice); |
| 153 | if (challenge != nullptr) { |
| 154 | challengeType = choice; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 155 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 156 | else { |
| 157 | std::cerr << "Cannot recognize the specified challenge. Exit"; |
| 158 | return; |
| 159 | } |
| 160 | auto requirement = challenge->getRequirementForChallenge(client.getApplicationStatus(), |
| 161 | client.getChallengeStatus()); |
| 162 | if (requirement.size() > 0) { |
| 163 | std::cerr << "Step " << nStep++ << ": Please satisfy following instruction(s)\n"; |
| 164 | std::string redo = ""; |
| 165 | std::list<std::string> capturedParams; |
| 166 | do { |
| 167 | capturedParams = captureParams(requirement); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 168 | std::cerr << "If everything is right, please type in OK; otherwise, type in REDO" << std::endl; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 169 | getline(std::cin, redo); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 170 | std::transform(redo.begin(), redo.end(), redo.begin(), ::toupper); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 171 | } while (redo == "REDO"); |
| 172 | auto it1 = capturedParams.begin(); |
| 173 | auto it2 = requirement.begin(); |
| 174 | for (; it1 != capturedParams.end() && it2 != requirement.end(); it1++, it2++) { |
| 175 | it2->second.put("", *it1); |
| 176 | } |
| 177 | } |
| 178 | face.expressInterest(*client.generateChallengeInterest( |
| 179 | challenge->genChallengeRequestJson( |
| 180 | client.getApplicationStatus(), |
| 181 | client.getChallengeStatus(), |
| 182 | requirement)), |
| 183 | bind(&challengeCb, _2), |
| 184 | bind(&onNackCb), |
| 185 | bind(&timeoutCb)); |
| 186 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 187 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 188 | static void |
| 189 | probeInfoCb(const Data& reply) |
| 190 | { |
| 191 | auto contentJson = ClientModule::getJsonFromData(reply); |
| 192 | auto caItem = ClientConfig::extractCaItem(contentJson); |
| 193 | |
| 194 | std::cerr << "Will install new trust anchor, please double check the identity info: \n" |
| 195 | << "This trust anchor packet is signed by " << reply.getSignature().getKeyLocator() << std::endl |
| 196 | << "The signing certificate is " << caItem.m_anchor << std::endl; |
| 197 | std::cerr << "Do you trust the information? Type in YES or NO" << std::endl; |
| 198 | |
| 199 | std::string answer; |
| 200 | getline(std::cin, answer); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 201 | std::transform(answer.begin(), answer.end(), answer.begin(), ::toupper); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 202 | if (answer == "YES") { |
| 203 | client.onProbeInfoResponse(reply); |
| 204 | std::cerr << "You answered YES: new CA installed" << std::endl; |
| 205 | startApplication(); |
| 206 | } |
| 207 | else { |
| 208 | std::cerr << "New CA not installed" << std::endl; |
| 209 | return; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | static void |
| 214 | probeCb(const Data& reply) |
| 215 | { |
Zhiyi Zhang | 781a560 | 2019-06-26 19:05:04 -0700 | [diff] [blame] | 216 | client.onProbeResponse(reply); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 217 | std::cerr << "Step " << nStep++ |
| 218 | << ": Please type in your expected validity period of your certificate." |
| 219 | << " Type in a number in unit of hour. The CA may change the validity" |
| 220 | << " period if your expected period is too long." << std::endl; |
| 221 | std::string periodStr; |
Zhiyi Zhang | 1a735bc | 2019-07-04 21:36:49 -0700 | [diff] [blame^] | 222 | int hours = 0; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 223 | getline(std::cin, periodStr); |
Zhiyi Zhang | 1a735bc | 2019-07-04 21:36:49 -0700 | [diff] [blame^] | 224 | hours = std::stoi(periodStr); |
| 225 | while (hours <= 0) { |
| 226 | std::cerr << "Invalid period time: " << "Please input the period again." << std::endl; |
| 227 | getline(std::cin, periodStr); |
| 228 | try { |
| 229 | hours = std::stoi(periodStr); |
| 230 | } |
| 231 | catch (const std::exception& e) { |
| 232 | hours = -1; |
| 233 | } |
| 234 | } |
Zhiyi Zhang | 781a560 | 2019-06-26 19:05:04 -0700 | [diff] [blame] | 235 | auto probeToken = make_shared<Data>(reply); |
Zhiyi Zhang | 1a735bc | 2019-07-04 21:36:49 -0700 | [diff] [blame^] | 236 | auto now = time::system_clock::now(); |
| 237 | face.expressInterest(*client.generateNewInterest(now, now + time::hours(hours), |
Zhiyi Zhang | 781a560 | 2019-06-26 19:05:04 -0700 | [diff] [blame] | 238 | Name(), probeToken), |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 239 | bind(&newCb, _2), |
| 240 | bind(&onNackCb), |
| 241 | bind(&timeoutCb)); |
| 242 | } |
| 243 | |
| 244 | static void |
| 245 | startApplication() |
| 246 | { |
| 247 | nStep = 0; |
| 248 | auto caList = client.getClientConf().m_caItems; |
| 249 | int count = 0; |
| 250 | for (auto item : caList) { |
| 251 | std::cerr << "***************************************\n" |
| 252 | << "Index: " << count++ << "\n" |
| 253 | << "CA prefix:" << item.m_caName << "\n" |
| 254 | << "Introduction: " << item.m_caInfo << "\n" |
| 255 | << "***************************************\n"; |
| 256 | } |
| 257 | std::vector<ClientCaItem> caVector{std::begin(caList), std::end(caList)}; |
| 258 | std::cerr << "Step " |
| 259 | << nStep++ << ": Please type in the CA INDEX that you want to apply" |
| 260 | << " or type in NONE if your expected CA is not in the list\n"; |
| 261 | |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 262 | std::string caIndexS, caIndexSUpper; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 263 | getline(std::cin, caIndexS); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 264 | caIndexSUpper = caIndexS; |
| 265 | std::transform(caIndexSUpper.begin(), caIndexSUpper.end(), caIndexSUpper.begin(), ::toupper); |
| 266 | if (caIndexSUpper == "NONE") { |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 267 | std::cerr << "Step " << nStep << ": Please type in the CA Name\n"; |
| 268 | face.expressInterest(*client.generateProbeInfoInterest(Name(caIndexS)), |
| 269 | bind(&probeInfoCb, _2), |
| 270 | bind(&onNackCb), |
| 271 | bind(&timeoutCb)); |
| 272 | } |
| 273 | else { |
| 274 | int caIndex = std::stoi(caIndexS); |
| 275 | BOOST_ASSERT(caIndex <= count); |
| 276 | auto targetCaItem = caVector[caIndex]; |
| 277 | |
| 278 | if (targetCaItem.m_probe != "") { |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 279 | std::cerr << "Step " << nStep++ << ": Please provide information for name assignment" << std::endl; |
| 280 | std::vector<std::string> probeFields = ClientModule::parseProbeComponents(targetCaItem.m_probe); |
| 281 | std::string redo = ""; |
| 282 | std::list<std::string> capturedParams; |
| 283 | do { |
| 284 | capturedParams = captureParams(probeFields); |
| 285 | std::cerr << "If everything is right, please type in OK; otherwise, type in REDO" << std::endl; |
| 286 | getline(std::cin, redo); |
| 287 | std::transform(redo.begin(), redo.end(), redo.begin(), ::toupper); |
| 288 | } while (redo == "REDO"); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 289 | std::string probeInfo; |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 290 | for (const auto& item : capturedParams) { |
| 291 | probeInfo += item; |
| 292 | probeInfo += ":"; |
| 293 | } |
| 294 | probeInfo = probeInfo.substr(0, probeInfo.size() - 1); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 295 | face.expressInterest(*client.generateProbeInterest(targetCaItem, probeInfo), |
| 296 | bind(&probeCb, _2), |
| 297 | bind(&onNackCb), |
| 298 | bind(&timeoutCb)); |
| 299 | } |
| 300 | else { |
| 301 | std::cerr << "Step " << nStep++ << ": Please type in the identity name you want to get (with CA prefix)\n"; |
| 302 | std::string identityNameStr; |
| 303 | getline(std::cin, identityNameStr); |
| 304 | std::cerr << "Step " |
| 305 | << nStep++ << ": Please type in your expected validity period of your certificate." |
| 306 | << "Type in a number in unit of hour." |
| 307 | << " The CA may change the validity period if your expected period is too long.\n"; |
| 308 | std::string periodStr; |
| 309 | getline(std::cin, periodStr); |
| 310 | int hours = std::stoi(periodStr); |
Zhiyi Zhang | 1a735bc | 2019-07-04 21:36:49 -0700 | [diff] [blame^] | 311 | auto now = time::system_clock::now(); |
| 312 | face.expressInterest(*client.generateNewInterest(now, now + time::hours(hours), |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 313 | Name(identityNameStr)), |
| 314 | bind(&newCb, _2), |
| 315 | bind(&onNackCb), |
| 316 | bind(&timeoutCb)); |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 321 | |
| 322 | int |
| 323 | main(int argc, char* argv[]) |
| 324 | { |
| 325 | namespace po = boost::program_options; |
| 326 | std::string configFilePath = std::string(SYSCONFDIR) + "/ndncert/client.conf"; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 327 | po::options_description description("General Usage\n ndncert-client [-h] [-f]\n"); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 328 | description.add_options() |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 329 | ("help,h", "produce help message") |
| 330 | ("config-file,f", po::value<std::string>(&configFilePath), "config file name"); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 331 | po::positional_options_description p; |
| 332 | |
| 333 | po::variables_map vm; |
| 334 | try { |
| 335 | po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm); |
| 336 | po::notify(vm); |
| 337 | } |
| 338 | catch (const std::exception& e) { |
| 339 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 340 | return 1; |
| 341 | } |
| 342 | if (vm.count("help") != 0) { |
| 343 | std::cerr << description << std::endl; |
| 344 | return 0; |
| 345 | } |
Zhiyi Zhang | d8993b9 | 2019-07-04 21:58:10 -0700 | [diff] [blame] | 346 | try { |
| 347 | client.getClientConf().load(configFilePath); |
| 348 | } |
| 349 | catch (const std::exception& e) { |
| 350 | std::cerr << "Cannot load the configuration file: " << e.what() << std::endl; |
| 351 | return 1; |
| 352 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 353 | startApplication(); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 354 | face.processEvents(); |
| 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | } // namespace ndncert |
| 359 | } // namespace ndn |
| 360 | |
Zhiyi Zhang | 916ba2d | 2018-02-01 18:16:27 -0800 | [diff] [blame] | 361 | int main(int argc, char* argv[]) |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 362 | { |
| 363 | return ndn::ndncert::main(argc, argv); |
| 364 | } |