blob: c757d45190d1f255ca699761b5af2a5d0fc848d0 [file] [log] [blame]
Zhiyi Zhang08e0e982017-03-01 10:10:42 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017, Regents of the University of California.
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 "ca-module.hpp"
22
Zhiyi Zhangb6fab0f2017-09-21 16:26:27 -070023#include <iostream>
24
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080025#include <boost/program_options/options_description.hpp>
26#include <boost/program_options/variables_map.hpp>
27#include <boost/program_options/parsers.hpp>
28
29namespace ndn {
30namespace ndncert {
31
32int
33main(int argc, char* argv[])
34{
35 namespace po = boost::program_options;
36 std::string configFilePath = std::string(SYSCONFDIR) + "/ndncert/ca.conf";
37 po::options_description description("General Usage\n ndncert-ca [-h] [-f] configFilePath-file\n");
38 description.add_options()
39 ("help,h", "produce help message")
40 ("config-file,f", po::value<std::string>(&configFilePath), "config file name");
41 po::positional_options_description p;
42 po::variables_map vm;
43 try {
44 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
45 po::notify(vm);
46 }
47 catch (const std::exception& e) {
48 std::cerr << "ERROR: " << e.what() << std::endl;
49 return 1;
50 }
51 if (vm.count("help") != 0) {
52 std::cerr << description << std::endl;
53 return 0;
54 }
55
56 Face face;
57 security::v2::KeyChain keyChain;
58 CaModule ca(face, keyChain, configFilePath);
59
60 ca.setProbeHandler([&] (const std::string& probeInfo) {
61 return probeInfo;
62 });
63 face.processEvents();
64
65 return 0;
66}
67
68} // namespace ndncert
69} // namespace ndn
70
71int
72main(int argc, char* argv[])
73{
74 return ndn::ndncert::main(argc, argv);
75}