Fix bug in challenge module about component index. Also add some LOG points

Change-Id: I8ec737ef9d7177becbe84055efa2438efab02225
diff --git a/src/challenge-module.cpp b/src/challenge-module.cpp
index 6a28866..c7ab849 100644
--- a/src/challenge-module.cpp
+++ b/src/challenge-module.cpp
@@ -19,11 +19,14 @@
  */
 
 #include "challenge-module.hpp"
+#include "logging.hpp"
 #include <random>
 
 namespace ndn {
 namespace ndncert {
 
+_LOG_INIT(ndncert.pinchallenge);
+
 const std::string ChallengeModule::WAIT_SELECTION = "wait-selection";
 const std::string ChallengeModule::SUCCESS = "success";
 const std::string ChallengeModule::PENDING = "pending";
@@ -44,9 +47,12 @@
 JsonSection
 ChallengeModule::handleChallengeRequest(const Interest& interest, CertificateRequest& request)
 {
-  int pos = request.getCaName().size();
+  int pos = request.getCaName().size() + 1;
   const Name& interestName = interest.getName();
   std::string interestType = interestName.get(pos).toUri();
+
+  _LOG_TRACE("Incoming challenge request. type: " << interestType);
+
   if (interestType == "_SELECT") {
     return processSelectInterest(interest, request);
   }