security: add key name sanity checking in KeyChain::selfSign

Change-Id: I2693fd9cf780a52af44b778d828069b5d01b8e8b
diff --git a/include/ndn-cpp/security/key-chain.hpp b/include/ndn-cpp/security/key-chain.hpp
index 2696fdf..9eb0b13 100644
--- a/include/ndn-cpp/security/key-chain.hpp
+++ b/include/ndn-cpp/security/key-chain.hpp
@@ -262,6 +262,9 @@
   ptr_lib::shared_ptr<IdentityCertificate>
   selfSign(const Name& keyName)
   {
+    if(keyName.empty())
+      throw std::runtime_error("Incorrect key name: " + keyName.toUri());
+
     ptr_lib::shared_ptr<IdentityCertificate> certificate = ptr_lib::make_shared<IdentityCertificate>();
     
     Name certificateName = keyName.getPrefix(-1);