ndnsec: improve error reporting when loading a Certificate or SafeBag fails
Refs: #5164
Change-Id: I6f594a921bb063ad808f311d8ff978bf0f7d528d
diff --git a/tools/ndnsec/import.cpp b/tools/ndnsec/import.cpp
index 7e27bee..2fb6755 100644
--- a/tools/ndnsec/import.cpp
+++ b/tools/ndnsec/import.cpp
@@ -23,7 +23,6 @@
#include "util.hpp"
#include "ndn-cxx/security/impl/openssl.hpp"
-#include "ndn-cxx/util/io.hpp"
#include "ndn-cxx/util/scope.hpp"
namespace ndn {
@@ -74,11 +73,7 @@
KeyChain keyChain;
- shared_ptr<security::SafeBag> safeBag;
- if (input == "-")
- safeBag = io::load<security::SafeBag>(std::cin);
- else
- safeBag = io::load<security::SafeBag>(input);
+ auto safeBag = loadFromFile<security::SafeBag>(input);
if (password.empty()) {
int count = 3;
@@ -91,7 +86,7 @@
}
}
- keyChain.importSafeBag(*safeBag, password.data(), password.size());
+ keyChain.importSafeBag(safeBag, password.data(), password.size());
return 0;
}