Re-add exception handler for dummy keychain

refs: #5206
Change-Id: I8099a99892e62c9365732a53b20f2f5030a67cc7
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index 205c67c..a7008e7 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -135,6 +135,11 @@
                    "If security is enabled in the configuration, NLSR will not converge.");
     return ndn::nullopt;
   }
+  catch (const std::invalid_argument& e) {
+    // This is (probably) needed for the dummy keychain patch.
+    // https://github.com/named-data/mini-ndn/blob/master/util/patches/ndn-cxx-dummy-keychain.patch
+    NLSR_LOG_DEBUG(e.what());
+  }
 
   auto instanceName = ndn::Name(m_routerPrefix).append("nlsr");
   try {
@@ -143,6 +148,15 @@
   catch (const Pib::Error&) {
     // old instance identity does not exist
   }
+  catch (const std::invalid_argument& e) {
+    // This is needed for the dummy-keychain patch (ref above) to handle the error that it generates.
+    const std::string exceptionText = e.what();
+    if (exceptionText.find("does not match identity") == std::string::npos) {
+      NLSR_LOG_ERROR(exceptionText);
+      throw;
+    }
+    return ndn::nullopt;
+  }
 
   auto key = m_keyChain.createIdentity(instanceName).getDefaultKey();
   auto cert = m_keyChain.makeCertificate(key, signingByIdentity(routerIdentity));