update requester and cmd line tool after testing cmd line tool

Change-Id: I301ac41a402ef3e808017aad9a79ddfe7117942d
diff --git a/src/requester.cpp b/src/requester.cpp
index 7530821..6c147e9 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -66,11 +66,24 @@
   if (!security::verifySignature(reply, *caItem.m_cert)) {
     _LOG_ERROR("Cannot verify replied Data packet signature.");
     BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
-    return boost::none;
   }
   return caItem;
 }
 
+
+boost::optional<CaProfile>
+Requester::onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName)
+{
+  auto caItem = INFO::decodeDataContent(reply.getContent());
+  auto certBlock = caItem.m_cert->wireEncode();
+  caItem.m_cert = std::make_shared<security::v2::Certificate>(certBlock);
+  if (caItem.m_cert->getFullName() != caCertFullName) {
+    _LOG_ERROR("Ca profile does not match the certificate information offered by the original CA.");
+    BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
+  }
+  return onCaProfileResponse(reply);
+}
+
 shared_ptr<Interest>
 Requester::genProbeInterest(const CaProfile& ca, std::vector<std::tuple<std::string, std::string>>&& probeInfo)
 {
@@ -272,7 +285,7 @@
 Requester::onCertFetchResponse(const Data& reply)
 {
   try {
-    return std::make_shared<security::v2::Certificate>(reply.getContent().blockFromValue());
+    return std::make_shared<security::v2::Certificate>(reply);
   }
   catch (const std::exception& e) {
     _LOG_ERROR("Cannot parse replied certificate ");
diff --git a/src/requester.hpp b/src/requester.hpp
index 7e40b9b..ab987dd 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -117,6 +117,9 @@
   static boost::optional<CaProfile>
   onCaProfileResponse(const Data& reply);
 
+  static boost::optional<CaProfile>
+  onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName);
+
   /**
    * Generates a PROBE interest to the CA (for suggested name assignments).
    * @param ca the CA that interest is send to