blob: e61f5b5d1da0b783317d8231b7d8a7a9b2d63d28 [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
23#include <boost/program_options/options_description.hpp>
24#include <boost/program_options/variables_map.hpp>
25#include <boost/program_options/parsers.hpp>
26
27namespace ndn {
28namespace ndncert {
29
30int
31main(int argc, char* argv[])
32{
33 namespace po = boost::program_options;
34 std::string configFilePath = std::string(SYSCONFDIR) + "/ndncert/ca.conf";
35 po::options_description description("General Usage\n ndncert-ca [-h] [-f] configFilePath-file\n");
36 description.add_options()
37 ("help,h", "produce help message")
38 ("config-file,f", po::value<std::string>(&configFilePath), "config file name");
39 po::positional_options_description p;
40 po::variables_map vm;
41 try {
42 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
43 po::notify(vm);
44 }
45 catch (const std::exception& e) {
46 std::cerr << "ERROR: " << e.what() << std::endl;
47 return 1;
48 }
49 if (vm.count("help") != 0) {
50 std::cerr << description << std::endl;
51 return 0;
52 }
53
54 Face face;
55 security::v2::KeyChain keyChain;
56 CaModule ca(face, keyChain, configFilePath);
57
58 ca.setProbeHandler([&] (const std::string& probeInfo) {
59 return probeInfo;
60 });
61 face.processEvents();
62
63 return 0;
64}
65
66} // namespace ndncert
67} // namespace ndn
68
69int
70main(int argc, char* argv[])
71{
72 return ndn::ndncert::main(argc, argv);
73}