tools: Convert ndnsec to v2::KeyChain
This commit removes the following tools:
- cert-revoke (wasn't working properly before and need a new
design)
- set-acl (wasn't working before)
- dsk-gen (no longer makes sense with the new certificate naming
conventions, new tools for creating derivative certificates will
be created later)
This commit also fixes Bug #3644 causing import command to ask for
unnecessary password confirmation.
ndnsec main now catch all exceptions logs the extended message
Change-Id: Ib50e0994970020bcf0a1840aca6bc3942818094b
Refs: #3098, #3644
diff --git a/tools/ndnsec/util.cpp b/tools/ndnsec/util.cpp
index 7afa036..52657f7 100644
--- a/tools/ndnsec/util.cpp
+++ b/tools/ndnsec/util.cpp
@@ -25,11 +25,9 @@
namespace ndnsec {
bool
-getPassword(std::string& password, const std::string& prompt)
+getPassword(std::string& password, const std::string& prompt, bool shouldConfirm)
{
#ifdef NDN_CXX_HAVE_GETPASS
- bool isReady = false;
-
char* pw0 = nullptr;
pw0 = getpass(prompt.c_str());
@@ -38,6 +36,10 @@
std::string password1 = pw0;
memset(pw0, 0, strlen(pw0));
+ if (!shouldConfirm) {
+ return true;
+ }
+
pw0 = getpass("Confirm:");
if (!pw0) {
char* pw1 = const_cast<char*>(password1.c_str());
@@ -45,6 +47,8 @@
return false;
}
+ bool isReady = false;
+
if (!password1.compare(pw0)) {
isReady = true;
password.swap(password1);
@@ -63,13 +67,19 @@
#endif // NDN_CXX_HAVE_GETPASS
}
-shared_ptr<security::v1::IdentityCertificate>
-getIdentityCertificate(const std::string& fileName)
+security::v2::Certificate
+loadCertificate(const std::string& fileName)
{
+ shared_ptr<security::v2::Certificate> cert;
if (fileName == "-")
- return io::load<security::v1::IdentityCertificate>(std::cin);
+ cert = io::load<security::v2::Certificate>(std::cin);
else
- return io::load<security::v1::IdentityCertificate>(fileName);
+ cert = io::load<security::v2::Certificate>(fileName);
+
+ if (cert == nullptr) {
+ BOOST_THROW_EXCEPTION(CannotLoadCertificate(fileName));
+ }
+ return *cert;
}
} // namespace ndnsec