security: Enable validator fetch cert directly from interest sender
Change-Id: I8fab50145a9a053c85c1b2c6be752ba71b0120ef
Refs: #2237
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 84aaa0f..d3af387 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -17,13 +17,11 @@
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
- * @author Jeff Thompson <jefft0@remap.ucla.edu>
*/
#include "validator.hpp"
#include "../util/crypto.hpp"
+#include "../lp/tags.hpp"
#include "v1/cryptopp.hpp"
@@ -35,11 +33,12 @@
Validator::Validator(Face* face)
: m_face(face)
+ , m_wantDirectCertFetch(false)
{
}
Validator::Validator(Face& face)
- : m_face(&face)
+ : Validator(&face)
{
}
@@ -311,6 +310,12 @@
}
for (shared_ptr<ValidationRequest> step : nextSteps) {
+ if (m_wantDirectCertFetch && step->m_requesterFaceId != 0) {
+ Interest directFetchInterest(step->m_interest);
+ directFetchInterest.refreshNonce();
+ directFetchInterest.setTag(make_shared<lp::NextHopFaceIdTag>(step->m_requesterFaceId));
+ m_face->expressInterest(directFetchInterest, nullptr, nullptr, nullptr);
+ }
m_face->expressInterest(step->m_interest,
bind(&Validator::onData, this, _1, _2, step),
bind(&Validator::onNack, this, _1, _2,
@@ -322,5 +327,11 @@
}
}
+void
+Validator::setDirectCertFetchEnabled(bool isEnabled)
+{
+ m_wantDirectCertFetch = isEnabled;
+}
+
} // namespace security
} // namespace ndn