Prepare for testbed deployment: update ndncert-client
Change-Id: I0a84e2ebb913166b5fbdb16fdc0938862ba42a22
diff --git a/src/requester-request.cpp b/src/requester-request.cpp
index 7c5ab3c..60442c1 100644
--- a/src/requester-request.cpp
+++ b/src/requester-request.cpp
@@ -118,41 +118,23 @@
}
std::shared_ptr<Interest>
-Request::genNewInterest(const Name& newIdentityName,
+Request::genNewInterest(const Name& keyName,
const time::system_clock::TimePoint& notBefore,
const time::system_clock::TimePoint& notAfter)
{
- if (!m_caProfile.caPrefix.isPrefixOf(newIdentityName)) {
+ if (!m_caProfile.caPrefix.isPrefixOf(keyName)) {
return nullptr;
}
- if (newIdentityName.empty()) {
- NDN_LOG_TRACE("Randomly create a new name because newIdentityName is empty and the param is empty.");
- m_identityName = m_caProfile.caPrefix;
- m_identityName.append(ndn::to_string(ndn::random::generateSecureWord64()));
+ if (keyName.empty()) {
+ return nullptr;
}
else {
- m_identityName = newIdentityName;
- }
-
- // generate a newly key pair or use an existing key
- const auto& pib = m_keyChain.getPib();
- ndn::security::pib::Identity identity;
- try {
+ const auto& pib = m_keyChain.getPib();
+ ndn::security::pib::Identity identity;
+ m_identityName = ndn::security::extractIdentityFromKeyName(keyName);
identity = pib.getIdentity(m_identityName);
+ m_keyPair = identity.getKey(keyName);
}
- catch (const ndn::security::Pib::Error&) {
- identity = m_keyChain.createIdentity(m_identityName);
- m_isNewlyCreatedIdentity = true;
- m_isNewlyCreatedKey = true;
- }
- try {
- m_keyPair = identity.getDefaultKey();
- }
- catch (const ndn::security::Pib::Error&) {
- m_keyPair = m_keyChain.createKey(identity);
- m_isNewlyCreatedKey = true;
- }
- auto& keyName = m_keyPair.getName();
// generate certificate request
Certificate certRequest;
@@ -289,25 +271,6 @@
}
void
-Request::endSession()
-{
- if (m_status == Status::SUCCESS) {
- return;
- }
-
- if (m_isNewlyCreatedIdentity) {
- // put the identity into the if scope is because it may cause an error
- // outside since when endSession is called, identity may not have been created yet.
- auto identity = m_keyChain.getPib().getIdentity(m_identityName);
- m_keyChain.deleteIdentity(identity);
- }
- else if (m_isNewlyCreatedKey) {
- auto identity = m_keyChain.getPib().getIdentity(m_identityName);
- m_keyChain.deleteKey(identity, m_keyPair);
- }
-}
-
-void
Request::processIfError(const Data& data)
{
auto errorInfo = errortlv::decodefromDataContent(data.getContent());
diff --git a/src/requester-request.hpp b/src/requester-request.hpp
index 9291958..0f8447a 100644
--- a/src/requester-request.hpp
+++ b/src/requester-request.hpp
@@ -112,13 +112,13 @@
* @brief Generates a NEW interest to the CA.
*
* @param state The current requester state for this request. Will be modified in the function.
- * @param newIdentityName The identity name to be requested.
+ * @param keyName The key name to be requested.
* @param notBefore The expected notBefore field for the certificate (starting time)
* @param notAfter The expected notAfter field for the certificate (expiration time)
* @return The shared pointer to the encoded interest.
*/
std::shared_ptr<Interest>
- genNewInterest(const Name& newIdentityName,
+ genNewInterest(const Name& keyName,
const time::system_clock::TimePoint& notBefore,
const time::system_clock::TimePoint& notAfter);
@@ -195,14 +195,6 @@
static std::shared_ptr<Certificate>
onCertFetchResponse(const Data& reply);
- /**
- * @brief End the current request session and performs cleanup if necessary.
- *
- * @param state, the requester state for the request.
- */
- void
- endSession();
-
private:
static void
processIfError(const Data& data);
@@ -279,11 +271,6 @@
*/
ndn::KeyChain& m_keyChain;
/**
- * @brief State about how identity/key is generated.
- */
- bool m_isNewlyCreatedIdentity = false;
- bool m_isNewlyCreatedKey = false;
- /**
* @brief The keypair for the request.
*/
ndn::security::Key m_keyPair;