tools+security: Add empty pointer checking in ndnsec-cert-gen

Change-Id: I096fea55fe05b01840d9bb718d0bab61e56cd3cd
diff --git a/tools/ndnsec-cert-gen.hpp b/tools/ndnsec-cert-gen.hpp
index 264dfab..71b2035 100644
--- a/tools/ndnsec-cert-gen.hpp
+++ b/tools/ndnsec-cert-gen.hpp
@@ -191,6 +191,13 @@
                                                 signIdName, notBefore, notAfter,
                                                 subjectDescription, prefix);
 
+  if (!static_cast<bool>(certificate))
+    {
+      std::cerr << "ERROR: key name is not formated correctly or does not match certificate name."
+                << std::endl;
+      return 1;
+    }
+
   keyChain.createIdentity(signIdName);
   Name signingCertificateName = keyChain.getDefaultCertificateNameForIdentity(signIdName);
   keyChain.sign(*certificate, signingCertificateName);