Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
swa770 | 20643ac | 2020-03-26 02:24:45 -0700 | [diff] [blame] | 2 | /** |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2020, 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 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 21 | #include "requester-request.hpp" |
Zhiyi Zhang | 90c7578 | 2020-10-06 15:04:03 -0700 | [diff] [blame] | 22 | #include <ndn-cxx/security/verification-helpers.hpp> |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 23 | #include <boost/asio.hpp> |
Davide Pesavento | b48bbda | 2020-07-27 19:41:37 -0400 | [diff] [blame] | 24 | #include <boost/program_options/options_description.hpp> |
| 25 | #include <boost/program_options/parsers.hpp> |
| 26 | #include <boost/program_options/variables_map.hpp> |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 27 | #include <iostream> |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 28 | #include <string> |
| 29 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 30 | namespace ndn { |
| 31 | namespace ndncert { |
Zhiyi Zhang | 3002e6b | 2020-10-29 18:54:07 -0700 | [diff] [blame] | 32 | namespace requester { |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 33 | |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 34 | static void |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 35 | selectCaProfile(std::string configFilePath); |
| 36 | static void |
| 37 | runProbe(CaProfile profile); |
| 38 | static void |
| 39 | runNew(CaProfile profile, Name identityName); |
| 40 | static void |
| 41 | runChallenge(const std::string& challengeType); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 42 | |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 43 | size_t nStep = 1; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 44 | Face face; |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 45 | security::KeyChain keyChain; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 46 | shared_ptr<Request> requesterState = nullptr; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 47 | |
Zhiyi Zhang | 4604983 | 2020-09-28 17:08:12 -0700 | [diff] [blame] | 48 | static void |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 49 | captureParams(std::multimap<std::string, std::string>& requirement) |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 50 | { |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 51 | std::list<std::string> results; |
Zhiyi Zhang | 4604983 | 2020-09-28 17:08:12 -0700 | [diff] [blame] | 52 | for (auto& item : requirement) { |
| 53 | std::cerr << std::get<1>(item) << std::endl; |
| 54 | std::string captured; |
| 55 | getline(std::cin, captured); |
| 56 | std::get<1>(item) = captured; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 57 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 58 | std::cerr << "Got it. This is what you've provided:" << std::endl; |
Zhiyi Zhang | 4604983 | 2020-09-28 17:08:12 -0700 | [diff] [blame] | 59 | for (const auto& item : requirement) { |
| 60 | std::cerr << std::get<0>(item) << " : " << std::get<1>(item) << std::endl; |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 61 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 62 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 63 | |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 64 | static std::multimap<std::string, std::string> |
Zhiyi Zhang | 2de4ea3 | 2020-12-13 17:45:25 -0800 | [diff] [blame] | 65 | captureParams(const std::vector<std::string>& requirement) |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 66 | { |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 67 | std::multimap<std::string, std::string> results; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 68 | for (const auto& r : requirement) { |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 69 | results.emplace(r, "Please input: " + r); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 70 | } |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 71 | captureParams(results); |
Zhiyi Zhang | 547c851 | 2019-06-18 23:46:14 -0700 | [diff] [blame] | 72 | return results; |
| 73 | } |
| 74 | |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 75 | static int |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 76 | captureValidityPeriod() |
| 77 | { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 78 | std::cerr << "\n***************************************\n" |
| 79 | << "Step " << nStep++ |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 80 | << ": Please type in your expected validity period of your certificate." |
| 81 | << " Type the number of hours (168 for week, 730 for month, 8760 for year)." |
| 82 | << " The CA may reject your application if your expected period is too long." << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 83 | size_t count = 0; |
| 84 | while (true && count < 3) { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 85 | std::string periodStr = ""; |
| 86 | getline(std::cin, periodStr); |
| 87 | try { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 88 | return std::stoul(periodStr); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 89 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 90 | catch (const std::exception& e) { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 91 | std::cerr << "Your input is invalid. Try again: " << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 92 | count++; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 93 | } |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 94 | } |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 95 | std::cerr << "Invalid input for too many times, exit. " << std::endl; |
| 96 | exit(1); |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static void |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 100 | onNackCb() |
| 101 | { |
| 102 | std::cerr << "Got NACK\n"; |
| 103 | } |
| 104 | |
| 105 | static void |
| 106 | timeoutCb() |
| 107 | { |
| 108 | std::cerr << "Interest sent time out\n"; |
| 109 | } |
| 110 | |
| 111 | static void |
swa770 | cf1d8f7 | 2020-04-21 23:12:39 -0700 | [diff] [blame] | 112 | certFetchCb(const Data& reply) |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 113 | { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 114 | auto item = Request::onCertFetchResponse(reply); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 115 | if (item) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 116 | keyChain.addCertificate(keyChain.getPib().getIdentity(item->getIdentity()).getKey(item->getKeyName()), *item); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 117 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 118 | std::cerr << "\n***************************************\n" |
| 119 | << "Step " << nStep++ |
| 120 | << ": DONE\nCertificate with Name: " << reply.getName().toUri() |
| 121 | << "has already been installed to your local keychain" << std::endl |
| 122 | << "Exit now"; |
| 123 | face.getIoService().stop(); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static void |
| 127 | challengeCb(const Data& reply) |
| 128 | { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 129 | try { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 130 | requesterState->onChallengeResponse(reply); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 131 | } |
| 132 | catch (const std::exception& e) { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 133 | std::cerr << "Error when decoding challenge step: " << e.what() << std::endl; |
| 134 | exit(1); |
| 135 | } |
tylerliu | f2e6bb5 | 2020-12-13 13:23:05 -0800 | [diff] [blame] | 136 | if (requesterState->status == Status::SUCCESS) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 137 | std::cerr << "Certificate has already been issued, downloading certificate..." << std::endl; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 138 | face.expressInterest(*requesterState->genCertFetchInterest(), bind(&certFetchCb, _2), |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 139 | bind(&onNackCb), bind(&timeoutCb)); |
Zhiyi Zhang | 4d89fe0 | 2017-04-28 18:51:51 -0700 | [diff] [blame] | 140 | return; |
| 141 | } |
tylerliu | f2e6bb5 | 2020-12-13 13:23:05 -0800 | [diff] [blame] | 142 | runChallenge(requesterState->challengeType); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 143 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 144 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 145 | static void |
| 146 | newCb(const Data& reply) |
| 147 | { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 148 | std::list<std::string> challengeList; |
| 149 | try { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 150 | challengeList = requesterState->onNewRenewRevokeResponse(reply); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 151 | } |
| 152 | catch (const std::exception& e) { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 153 | std::cerr << "Error on decoding NEW step reply because: " << e.what() << std::endl; |
| 154 | exit(1); |
| 155 | } |
| 156 | |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 157 | size_t challengeIndex = 0; |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 158 | if (challengeList.size() < 1) { |
| 159 | std::cerr << "There is no available challenge provided by the CA. Exit" << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 160 | exit(1); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 161 | } |
Zhiyi Zhang | 48f546f | 2020-12-24 17:31:02 -0800 | [diff] [blame] | 162 | else if (challengeList.size() >= 1) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 163 | std::cerr << "\n***************************************\n" |
| 164 | << "Step " << nStep++ |
| 165 | << ": CHALLENGE SELECTION" << std::endl; |
| 166 | size_t count = 0; |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 167 | std::string choice = ""; |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 168 | for (auto item : challengeList) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 169 | std::cerr << "> Index: " << count++ << std::endl |
| 170 | << ">> Challenge:" << item << std::endl; |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 171 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 172 | std::cerr << "Please type in the challenge index that you want to perform:" << std::endl; |
Zhiyi Zhang | 17720f2 | 2021-01-08 14:12:56 -0800 | [diff] [blame] | 173 | size_t inputCount = 0; |
| 174 | while (inputCount < 3) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 175 | getline(std::cin, choice); |
| 176 | try { |
| 177 | challengeIndex = std::stoul(choice); |
| 178 | } |
| 179 | catch (const std::exception& e) { |
| 180 | std::cerr << "Your input is not valid. Try again:" << std::endl; |
Zhiyi Zhang | 17720f2 | 2021-01-08 14:12:56 -0800 | [diff] [blame] | 181 | inputCount++; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 182 | continue; |
| 183 | } |
| 184 | if (challengeIndex >= count) { |
| 185 | std::cerr << "Your input index is out of range. Try again:" << std::endl; |
Zhiyi Zhang | 17720f2 | 2021-01-08 14:12:56 -0800 | [diff] [blame] | 186 | inputCount++; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 187 | continue; |
| 188 | } |
| 189 | break; |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 190 | } |
Zhiyi Zhang | 17720f2 | 2021-01-08 14:12:56 -0800 | [diff] [blame] | 191 | if (inputCount == 3) { |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 192 | std::cerr << "Invalid input for too many times, exit. " << std::endl; |
| 193 | exit(1); |
| 194 | } |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 195 | } |
| 196 | auto it = challengeList.begin(); |
| 197 | std::advance(it, challengeIndex); |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 198 | std::cerr << "The challenge has been selected: " << *it << std::endl; |
| 199 | runChallenge(*it); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 200 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 201 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 202 | static void |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 203 | InfoCb(const Data& reply, const Name& certFullName) |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 204 | { |
Zhiyi Zhang | 997669a | 2020-10-28 21:15:40 -0700 | [diff] [blame] | 205 | optional<CaProfile> profile; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 206 | try { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 207 | if (certFullName.empty()) { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 208 | profile = Request::onCaProfileResponse(reply); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 209 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 210 | else { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 211 | profile = Request::onCaProfileResponseAfterRedirection(reply, certFullName); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | catch (const std::exception& e) { |
| 215 | std::cerr << "The fetched CA information cannot be used because: " << e.what() << std::endl; |
| 216 | return; |
Zhiyi Zhang | caab546 | 2019-10-18 13:41:02 -0700 | [diff] [blame] | 217 | } |
Zhiyi Zhang | 6bb1d08 | 2020-10-08 14:25:21 -0700 | [diff] [blame] | 218 | std::cerr << "\n***************************************\n" |
| 219 | << "Step " << nStep++ |
| 220 | << ": Will use a new trust anchor, please double check the identity info:" << std::endl |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 221 | << "> New CA name: " << profile->caPrefix.toUri() << std::endl |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 222 | << "> This trust anchor information is signed by: " << reply.getSignatureInfo().getKeyLocator() << std::endl |
Zhiyi Zhang | ec4aa3a | 2021-01-08 14:26:37 -0800 | [diff] [blame] | 223 | << "> The certificate: " << *profile->cert << std::endl |
Davide Pesavento | b48bbda | 2020-07-27 19:41:37 -0400 | [diff] [blame] | 224 | << "Do you trust the information? Type in YES or NO" << std::endl; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 225 | |
| 226 | std::string answer; |
| 227 | getline(std::cin, answer); |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 228 | boost::algorithm::to_lower(answer); |
| 229 | if (answer == "yes") { |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 230 | std::cerr << "You answered YES: new CA " << profile->caPrefix.toUri() << " will be used" << std::endl; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 231 | runProbe(*profile); |
Zhiyi Zhang | caab546 | 2019-10-18 13:41:02 -0700 | [diff] [blame] | 232 | // client.getClientConf().save(std::string(SYSCONFDIR) + "/ndncert/client.conf"); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 233 | } |
| 234 | else { |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 235 | std::cerr << "You answered NO: new CA " << profile->caPrefix.toUri() << " will not be used" << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 236 | exit(0); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
| 240 | static void |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 241 | probeCb(const Data& reply, CaProfile profile) |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 242 | { |
tylerliu | b47dad7 | 2020-10-08 21:36:55 -0700 | [diff] [blame] | 243 | std::vector<std::pair<Name, int>> names; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 244 | std::vector<Name> redirects; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 245 | Request::onProbeResponse(reply, profile, names, redirects); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 246 | size_t count = 0; |
| 247 | std::cerr << "\n***************************************\n" |
| 248 | << "Step " << nStep++ |
| 249 | << ": You can either select one of the following names suggested by the CA: " << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 250 | for (const auto& name : names) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 251 | std::cerr << "> Index: " << count++ << std::endl |
tylerliu | b47dad7 | 2020-10-08 21:36:55 -0700 | [diff] [blame] | 252 | << ">> Suggested name: " << name.first.toUri() << std::endl |
| 253 | << ">> Corresponding Max sufiix length: " << name.second << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 254 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 255 | std::cerr << "\nOr choose another trusted CA suggested by the CA: " << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 256 | for (const auto& redirect : redirects) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 257 | std::cerr << "> Index: " << count++ << std::endl |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 258 | << ">> Suggested CA: " << security::extractIdentityFromCertName(redirect.getPrefix(-1)) << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 259 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 260 | std::cerr << "Please type in the index of your choice:" << std::endl; |
| 261 | size_t index = 0; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 262 | try { |
| 263 | std::string input; |
| 264 | getline(std::cin, input); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 265 | index = std::stoul(input); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 266 | } |
| 267 | catch (const std::exception& e) { |
| 268 | std::cerr << "Your input is Invalid. Exit" << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 269 | exit(1); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 270 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 271 | if (index >= names.size() + redirects.size()) { |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 272 | std::cerr << "Your input is not an existing index. Exit" << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 273 | exit(1); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 274 | } |
| 275 | if (index < names.size()) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 276 | //names |
tylerliu | d82cc5c | 2020-12-21 23:58:39 -0800 | [diff] [blame] | 277 | auto selectedName = names[index].first; |
| 278 | std::cerr << "You selected name: " << selectedName.toUri() << std::endl; |
| 279 | std::cerr << "Enter Suffix if you would like one (Enter to skip): "; |
| 280 | try { |
| 281 | std::string input; |
| 282 | getline(std::cin, input); |
| 283 | auto inputName = Name(input); |
| 284 | if (!inputName.empty()) { |
| 285 | selectedName.append(inputName); |
| 286 | std::cerr << "You are applying name: " << selectedName.toUri() << std::endl; |
| 287 | } |
| 288 | } |
| 289 | catch (const std::exception& e) { |
| 290 | std::cerr << "Your input is Invalid. Exit" << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 291 | exit(1); |
tylerliu | d82cc5c | 2020-12-21 23:58:39 -0800 | [diff] [blame] | 292 | } |
| 293 | runNew(profile, selectedName); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 294 | } |
| 295 | else { |
| 296 | //redirects |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 297 | auto redirectedCaFullName = redirects[index - names.size()]; |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 298 | auto redirectedCaName = security::extractIdentityFromCertName(redirectedCaFullName.getPrefix(-1)); |
Zhiyi Zhang | 696cd04 | 2020-10-07 21:27:36 -0700 | [diff] [blame] | 299 | std::cerr << "You selected to be redirected to CA: " << redirectedCaName.toUri() << std::endl; |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 300 | face.expressInterest( |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 301 | *Request::genCaProfileDiscoveryInterest(redirectedCaName), |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 302 | [&](const Interest&, const Data& data) { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 303 | auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data); |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 304 | face.expressInterest(*fetchingInterest, |
| 305 | bind(&InfoCb, _2, redirectedCaFullName), |
| 306 | bind(&onNackCb), |
| 307 | bind(&timeoutCb)); |
| 308 | }, |
| 309 | bind(&onNackCb), |
| 310 | bind(&timeoutCb)); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
| 314 | static void |
| 315 | selectCaProfile(std::string configFilePath) |
| 316 | { |
Zhiyi Zhang | a16b758 | 2020-10-29 18:59:46 -0700 | [diff] [blame] | 317 | ProfileStorage profileStorage; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 318 | try { |
Zhiyi Zhang | a16b758 | 2020-10-29 18:59:46 -0700 | [diff] [blame] | 319 | profileStorage.load(configFilePath); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 320 | } |
| 321 | catch (const std::exception& e) { |
| 322 | std::cerr << "Cannot load the configuration file: " << e.what() << std::endl; |
| 323 | exit(1); |
| 324 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 325 | size_t count = 0; |
| 326 | std::cerr << "***************************************\n" |
| 327 | << "Step " << nStep++ << ": CA SELECTION" << std::endl; |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 328 | for (auto item : profileStorage.getKnownProfiles()) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 329 | std::cerr << "> Index: " << count++ << std::endl |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 330 | << ">> CA prefix:" << item.caPrefix << std::endl |
| 331 | << ">> Introduction: " << item.caInfo << std::endl; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 332 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 333 | std::cerr << "Please type in the CA's index that you want to apply or type in NONE if your expected CA is not in the list:\n"; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 334 | |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 335 | std::string caIndexS, caIndexSLower; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 336 | getline(std::cin, caIndexS); |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 337 | caIndexSLower = caIndexS; |
| 338 | boost::algorithm::to_lower(caIndexSLower); |
| 339 | if (caIndexSLower == "none") { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 340 | std::cerr << "\n***************************************\n" |
| 341 | << "Step " << nStep << ": ADD NEW CA\nPlease type in the CA's Name:" << std::endl; |
Zhiyi Zhang | caab546 | 2019-10-18 13:41:02 -0700 | [diff] [blame] | 342 | std::string expectedCAName; |
| 343 | getline(std::cin, expectedCAName); |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 344 | face.expressInterest( |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 345 | *Request::genCaProfileDiscoveryInterest(Name(expectedCAName)), |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 346 | [&](const Interest&, const Data& data) { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 347 | auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data); |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 348 | face.expressInterest(*fetchingInterest, |
| 349 | bind(&InfoCb, _2, Name()), |
| 350 | bind(&onNackCb), |
| 351 | bind(&timeoutCb)); |
| 352 | }, |
| 353 | bind(&onNackCb), |
| 354 | bind(&timeoutCb)); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 355 | } |
| 356 | else { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 357 | size_t caIndex; |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 358 | try { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 359 | caIndex = std::stoul(caIndexS); |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 360 | } |
| 361 | catch (const std::exception& e) { |
| 362 | std::cerr << "Your input is neither NONE nor a valid index. Exit" << std::endl; |
| 363 | return; |
| 364 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 365 | if (caIndex >= count) { |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 366 | std::cerr << "Your input is not an existing index. Exit" << std::endl; |
| 367 | return; |
| 368 | } |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 369 | auto itemIterator = profileStorage.getKnownProfiles().cbegin(); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 370 | std::advance(itemIterator, caIndex); |
| 371 | auto targetCaItem = *itemIterator; |
| 372 | runProbe(targetCaItem); |
| 373 | } |
| 374 | } |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 375 | |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 376 | static void |
| 377 | runProbe(CaProfile profile) |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 378 | { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 379 | std::cerr << "\n***************************************\n" |
Zhiyi Zhang | 6bb1d08 | 2020-10-08 14:25:21 -0700 | [diff] [blame] | 380 | << "Step " << nStep++ |
| 381 | << ": Do you know your identity name to be certified by CA " |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 382 | << profile.caPrefix.toUri() |
Zhiyi Zhang | 6bb1d08 | 2020-10-08 14:25:21 -0700 | [diff] [blame] | 383 | << " already? Type in YES or NO" << std::endl; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 384 | bool validAnswer = false; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 385 | size_t count = 0; |
| 386 | while (!validAnswer && count < 3) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 387 | std::string answer; |
| 388 | getline(std::cin, answer); |
| 389 | boost::algorithm::to_lower(answer); |
| 390 | if (answer == "yes") { |
| 391 | validAnswer = true; |
| 392 | std::cerr << "You answered YES" << std::endl; |
| 393 | std::cerr << "\n***************************************\n" |
| 394 | << "Step " << nStep++ |
Zhiyi Zhang | 6bb1d08 | 2020-10-08 14:25:21 -0700 | [diff] [blame] | 395 | << ": Please type in the full identity name you want to get (with CA prefix " |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 396 | << profile.caPrefix.toUri() |
Zhiyi Zhang | 6bb1d08 | 2020-10-08 14:25:21 -0700 | [diff] [blame] | 397 | << "):" << std::endl; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 398 | std::string identityNameStr; |
| 399 | getline(std::cin, identityNameStr); |
| 400 | runNew(profile, Name(identityNameStr)); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 401 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 402 | else if (answer == "no") { |
| 403 | validAnswer = true; |
| 404 | std::cerr << "You answered NO" << std::endl; |
| 405 | std::cerr << "\n***************************************\n" |
| 406 | << "Step " << nStep++ << ": Please provide information for name assignment" << std::endl; |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 407 | auto capturedParams = captureParams(profile.probeParameterKeys); |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 408 | face.expressInterest(*Request::genProbeInterest(profile, std::move(capturedParams)), |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 409 | bind(&probeCb, _2, profile), bind(&onNackCb), bind(&timeoutCb)); |
| 410 | } |
| 411 | else { |
| 412 | std::cerr << "Invalid answer. Type in YES or NO" << std::endl; |
Zhiyi Zhang | 87ded73 | 2021-01-08 14:05:24 -0800 | [diff] [blame] | 413 | count++; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
Zhiyi Zhang | 17720f2 | 2021-01-08 14:12:56 -0800 | [diff] [blame] | 416 | if (count == 3) { |
| 417 | std::cerr << "Invalid input for too many times, exit. " << std::endl; |
| 418 | exit(1); |
| 419 | } |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | static void |
| 423 | runNew(CaProfile profile, Name identityName) |
| 424 | { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 425 | int validityPeriod = captureValidityPeriod(); |
| 426 | auto now = time::system_clock::now(); |
| 427 | std::cerr << "The validity period of your certificate will be: " << validityPeriod << " hours" << std::endl; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 428 | requesterState = std::make_shared<Request>(keyChain, profile, RequestType::NEW); |
| 429 | auto interest = requesterState->genNewInterest(identityName, now, now + time::hours(validityPeriod)); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 430 | if (interest != nullptr) { |
| 431 | face.expressInterest(*interest, bind(&newCb, _2), bind(&onNackCb), bind(&timeoutCb)); |
| 432 | } |
| 433 | else { |
| 434 | std::cerr << "Cannot generate the Interest for NEW step. Exit" << std::endl; |
| 435 | } |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | static void |
| 439 | runChallenge(const std::string& challengeType) |
| 440 | { |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 441 | std::multimap<std::string, std::string> requirement; |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 442 | try { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 443 | requirement = requesterState->selectOrContinueChallenge(challengeType); |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 444 | } |
| 445 | catch (const std::exception& e) { |
| 446 | std::cerr << "Error. Cannot successfully load the Challenge Module with error: " << std::string(e.what()) |
| 447 | << "Exit." << std::endl; |
| 448 | exit(1); |
| 449 | } |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 450 | if (requirement.size() > 0) { |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 451 | std::cerr << "\n***************************************\n" |
| 452 | << "Step " << nStep |
| 453 | << ": Please provide parameters used for Identity Verification Challenge" << std::endl; |
| 454 | captureParams(requirement); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 455 | } |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 456 | face.expressInterest(*requesterState->genChallengeInterest(std::move(requirement)), |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 457 | bind(&challengeCb, _2), bind(&onNackCb), bind(&timeoutCb)); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 460 | static void |
| 461 | handleSignal(const boost::system::error_code& error, int signalNum) |
| 462 | { |
| 463 | if (error) { |
| 464 | return; |
| 465 | } |
| 466 | const char* signalName = ::strsignal(signalNum); |
| 467 | std::cerr << "Exiting on signal "; |
| 468 | if (signalName == nullptr) { |
| 469 | std::cerr << signalNum; |
| 470 | } |
| 471 | else { |
| 472 | std::cerr << signalName; |
| 473 | } |
| 474 | std::cerr << std::endl; |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 475 | if (requesterState) { |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame^] | 476 | requesterState->endSession(); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 477 | } |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 478 | face.getIoService().stop(); |
tylerliu | feabfdc | 2020-10-03 15:09:58 -0700 | [diff] [blame] | 479 | exit(1); |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 480 | } |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 481 | |
| 482 | int |
| 483 | main(int argc, char* argv[]) |
| 484 | { |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 485 | boost::asio::signal_set terminateSignals(face.getIoService()); |
| 486 | terminateSignals.add(SIGINT); |
| 487 | terminateSignals.add(SIGTERM); |
| 488 | terminateSignals.async_wait(handleSignal); |
| 489 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 490 | namespace po = boost::program_options; |
Zhiyi Zhang | 840afd9 | 2020-10-21 13:24:08 -0700 | [diff] [blame] | 491 | std::string configFilePath = std::string(NDNCERT_SYSCONFDIR) + "/ndncert/client.conf"; |
Zhiyi Zhang | 3670683 | 2019-07-04 21:33:03 -0700 | [diff] [blame] | 492 | po::options_description description("General Usage\n ndncert-client [-h] [-c] [-v]\n"); |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 493 | description.add_options()("help,h", "produce help message")("config-file,c", po::value<std::string>(&configFilePath), "configuration file name"); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 494 | po::positional_options_description p; |
| 495 | |
| 496 | po::variables_map vm; |
| 497 | try { |
| 498 | po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm); |
| 499 | po::notify(vm); |
| 500 | } |
| 501 | catch (const std::exception& e) { |
| 502 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 503 | return 1; |
| 504 | } |
| 505 | if (vm.count("help") != 0) { |
| 506 | std::cerr << description << std::endl; |
| 507 | return 0; |
| 508 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 509 | selectCaProfile(configFilePath); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 510 | face.processEvents(); |
| 511 | return 0; |
| 512 | } |
| 513 | |
Zhiyi Zhang | 3002e6b | 2020-10-29 18:54:07 -0700 | [diff] [blame] | 514 | } // namespace requester |
Zhiyi Zhang | e4891b7 | 2020-10-10 15:11:57 -0700 | [diff] [blame] | 515 | } // namespace ndncert |
| 516 | } // namespace ndn |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 517 | |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 518 | int |
| 519 | main(int argc, char* argv[]) |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 520 | { |
Zhiyi Zhang | 3002e6b | 2020-10-29 18:54:07 -0700 | [diff] [blame] | 521 | return ndn::ndncert::requester::main(argc, argv); |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 522 | } |