Add command line tools
Change-Id: I5bce4074324b35e5079b330dc20e14c22fc74c6b
diff --git a/tools/ndncert-ca-server.cpp b/tools/ndncert-ca-server.cpp
new file mode 100644
index 0000000..e61f5b5
--- /dev/null
+++ b/tools/ndncert-ca-server.cpp
@@ -0,0 +1,73 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#include "ca-module.hpp"
+
+#include <boost/program_options/options_description.hpp>
+#include <boost/program_options/variables_map.hpp>
+#include <boost/program_options/parsers.hpp>
+
+namespace ndn {
+namespace ndncert {
+
+int
+main(int argc, char* argv[])
+{
+ namespace po = boost::program_options;
+ std::string configFilePath = std::string(SYSCONFDIR) + "/ndncert/ca.conf";
+ po::options_description description("General Usage\n ndncert-ca [-h] [-f] configFilePath-file\n");
+ description.add_options()
+ ("help,h", "produce help message")
+ ("config-file,f", po::value<std::string>(&configFilePath), "config file name");
+ po::positional_options_description p;
+ po::variables_map vm;
+ try {
+ po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
+ po::notify(vm);
+ }
+ catch (const std::exception& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ return 1;
+ }
+ if (vm.count("help") != 0) {
+ std::cerr << description << std::endl;
+ return 0;
+ }
+
+ Face face;
+ security::v2::KeyChain keyChain;
+ CaModule ca(face, keyChain, configFilePath);
+
+ ca.setProbeHandler([&] (const std::string& probeInfo) {
+ return probeInfo;
+ });
+ face.processEvents();
+
+ return 0;
+}
+
+} // namespace ndncert
+} // namespace ndn
+
+int
+main(int argc, char* argv[])
+{
+ return ndn::ndncert::main(argc, argv);
+}