management: Fix regression with the prefix registration using the default certificate
This commit re-introduces a no longer deprecated feature in
ndn::nfd::Controller::start(ControlParameter,
CommandSuccessCallback, CommandFailCallback,
IdentityCertificate,
time::milliseconds),
which treats IdentityCertificate() (an invalid certificate that has an empty
name) as the default certificate.
Change-Id: I3f147260d649e82c6bd1927ff5998be79a37d0dc
Refs: #2080
diff --git a/src/management/nfd-controller.hpp b/src/management/nfd-controller.hpp
index ef82cac..f5eff7c 100644
--- a/src/management/nfd-controller.hpp
+++ b/src/management/nfd-controller.hpp
@@ -78,7 +78,12 @@
}
/** \brief start command execution
- * \param certificate the certificate used to sign request Interests
+ * \param certificate the certificate used to sign request Interests.
+ * If IdentityCertificate() is passed, the default signing certificate will be used.
+ *
+ * \note IdentityCertificate() creates a certificate with an empty name, which is an
+ * invalid certificate. A valid IdentityCertificate has at least 4 name components,
+ * as it follows `<...>/KEY/<...>/<key-id>/ID-CERT/<version>` naming model.
*/
template<typename Command>
void
@@ -88,10 +93,15 @@
const IdentityCertificate& certificate,
const time::milliseconds& timeout = getDefaultCommandTimeout())
{
- start<Command>(parameters, onSuccess, onFailure,
- bind(static_cast<void(KeyChain::*)(Interest&,const Name&)>(&KeyChain::sign<Interest>),
- &m_keyChain, _1, cref(certificate.getName())),
- timeout);
+ if (certificate.getName().empty()) {
+ start<Command>(parameters, onSuccess, onFailure, timeout);
+ }
+ else {
+ start<Command>(parameters, onSuccess, onFailure,
+ bind(static_cast<void(KeyChain::*)(Interest&,const Name&)>(&KeyChain::sign<Interest>),
+ &m_keyChain, _1, cref(certificate.getName())),
+ timeout);
+ }
}
/** \brief start command execution