use ndn::optional instead of boost::optional

Change-Id: If4db620ac410ddf5d8a082b26bdc8fef0b4c1b46
diff --git a/src/configuration.cpp b/src/configuration.cpp
index aab0df5..78c7e61 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -53,7 +53,11 @@
   // CA max validity period
   m_maxValidityPeriod = time::seconds(configJson.get(CONFIG_MAX_VALIDITY_PERIOD, 86400));
   // CA max suffix length
-  m_maxSuffixLength = configJson.get_optional<size_t>(CONFIG_MAX_SUFFIX_LENGTH);
+  m_maxSuffixLength = nullopt;
+  auto maxSuffixLength = configJson.get_optional<size_t>(CONFIG_MAX_SUFFIX_LENGTH);
+  if (maxSuffixLength.has_value()) {
+    m_maxSuffixLength = *maxSuffixLength;
+  }
   // probe parameter keys
   m_probeParameterKeys.clear();
   auto probeParametersJson = configJson.get_child_optional(CONFIG_PROBE_PARAMETERS);
@@ -99,7 +103,9 @@
   caItem.put(CONFIG_CA_PREFIX, m_caPrefix.toUri());
   caItem.put(CONFIG_CA_INFO, m_caInfo);
   caItem.put(CONFIG_MAX_VALIDITY_PERIOD, m_maxValidityPeriod.count());
-  caItem.put(CONFIG_MAX_SUFFIX_LENGTH, m_maxSuffixLength);
+  if (m_maxSuffixLength) {
+    caItem.put(CONFIG_MAX_SUFFIX_LENGTH, *m_maxSuffixLength);
+  }
   if (!m_probeParameterKeys.empty()) {
     JsonSection probeParametersJson;
     for (const auto& key : m_probeParameterKeys) {
@@ -144,7 +150,7 @@
     NDN_THROW(std::runtime_error("At least one challenge should be specified."));
   }
   // parse redirection section if appears
-  m_redirection = boost::none;
+  m_redirection = nullopt;
   auto redirectionItems = configJson.get_child_optional(CONFIG_REDIRECTION);
   if (redirectionItems) {
     for (const auto& item : *redirectionItems) {
diff --git a/src/configuration.hpp b/src/configuration.hpp
index c881786..8fc3c74 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -53,7 +53,7 @@
    * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
    * Default: none.
    */
-  boost::optional<size_t> m_maxSuffixLength;
+  optional<size_t> m_maxSuffixLength = nullopt;
   /**
    * A list of supported challenges. Only CA side will have m_supportedChallenges.
    * Default: empty list.
@@ -127,7 +127,7 @@
    * Used for CA redirection as specified in
    * https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3-PROBE-Extensions#probe-extension-for-redirection
    */
-  boost::optional<std::vector<std::shared_ptr<security::Certificate>>> m_redirection;
+  optional<std::vector<std::shared_ptr<security::Certificate>>> m_redirection = nullopt;
   /**
    * StatusUpdate Callback function
    */
diff --git a/src/detail/ca-state.hpp b/src/detail/ca-state.hpp
index 23ad6db..994d185 100644
--- a/src/detail/ca-state.hpp
+++ b/src/detail/ca-state.hpp
@@ -135,7 +135,7 @@
   /**
    * @brief The challenge state.
    */
-  boost::optional<ChallengeState> m_challengeState;
+  optional<ChallengeState> m_challengeState;
 };
 
 std::ostream&
diff --git a/src/detail/ndncert-common.hpp b/src/detail/ndncert-common.hpp
index 77f6ca2..0e1b392 100644
--- a/src/detail/ndncert-common.hpp
+++ b/src/detail/ndncert-common.hpp
@@ -48,6 +48,7 @@
 #include <ndn-cxx/security/certificate.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/util/logger.hpp>
+#include <ndn-cxx/util/nonstd/optional.hpp>
 #include <tuple>
 #include <boost/algorithm/string.hpp>
 #include <boost/assert.hpp>
diff --git a/src/detail/probe-encoder.cpp b/src/detail/probe-encoder.cpp
index 2908922..5141ba1 100644
--- a/src/detail/probe-encoder.cpp
+++ b/src/detail/probe-encoder.cpp
@@ -49,8 +49,8 @@
 }
 
 Block
-ProbeEncoder::encodeDataContent(const std::vector<Name>& identifiers, boost::optional<size_t> maxSuffixLength,
-                         boost::optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems)
+ProbeEncoder::encodeDataContent(const std::vector<Name>& identifiers, optional<size_t> maxSuffixLength,
+                         optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems)
 {
   Block content = makeEmptyBlock(ndn::tlv::Content);
   for (const auto& name : identifiers) {
diff --git a/src/detail/probe-encoder.hpp b/src/detail/probe-encoder.hpp
index 2e47e76..0a991c3 100644
--- a/src/detail/probe-encoder.hpp
+++ b/src/detail/probe-encoder.hpp
@@ -40,8 +40,8 @@
   // For CA use
   static Block
   encodeDataContent(const std::vector<Name>& identifiers,
-                    boost::optional<size_t> maxSuffixLength = boost::none,
-                    boost::optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems = boost::none);
+                    optional<size_t> maxSuffixLength = nullopt,
+                    optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems = nullopt);
 
   static std::vector<std::tuple<std::string, std::string>>
   decodeApplicationParameters(const Block& block);
diff --git a/src/identity-challenge/challenge-module.cpp b/src/identity-challenge/challenge-module.cpp
index 0570ed5..03feeeb 100644
--- a/src/identity-challenge/challenge-module.cpp
+++ b/src/identity-challenge/challenge-module.cpp
@@ -77,7 +77,7 @@
 {
   request.m_status = Status::FAILURE;
   request.m_challengeType = "";
-  request.m_challengeState = boost::none;
+  request.m_challengeState = nullopt;
   return std::make_tuple(errorCode, std::move(errorInfo));
 }
 
@@ -96,7 +96,7 @@
 {
   request.m_status = Status::PENDING;
   request.m_challengeType = CHALLENGE_TYPE;
-  request.m_challengeState = boost::none;
+  request.m_challengeState = nullopt;
   return std::make_tuple(ErrorCode::NO_ERROR, "");
 }
 
diff --git a/src/requester.cpp b/src/requester.cpp
index 8ae64eb..af3f6c4 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -62,7 +62,7 @@
   return interest;
 }
 
-boost::optional<CaProfile>
+optional<CaProfile>
 Requester::onCaProfileResponse(const Data& reply)
 {
   auto caItem = InfoEncoder::decodeDataContent(reply.getContent());
@@ -74,7 +74,7 @@
 }
 
 
-boost::optional<CaProfile>
+optional<CaProfile>
 Requester::onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName)
 {
   auto caItem = InfoEncoder::decodeDataContent(reply.getContent());
diff --git a/src/requester.hpp b/src/requester.hpp
index b3c7901..cb3d10d 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -61,7 +61,7 @@
    * @return the CaProfile if decoding is successful
    * @throw std::runtime_error if the decoding fails or receiving an error packet.
    */
-  static boost::optional<CaProfile>
+  static optional<CaProfile>
   onCaProfileResponse(const Data& reply);
 
   /**
@@ -76,7 +76,7 @@
    * @return the CaProfile if decoding is successful
    * @throw std::runtime_error if the decoding fails or receiving an error packet.
    */
-  static boost::optional<CaProfile>
+  static optional<CaProfile>
   onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName);
 
   /**
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 7d5c901..e887165 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -45,7 +45,7 @@
   BOOST_CHECK_EQUAL(config.m_caItem.m_caPrefix, "/ndn");
   BOOST_CHECK_EQUAL(config.m_caItem.m_caInfo, "missing max validity period, max suffix length, and probe");
   BOOST_CHECK_EQUAL(config.m_caItem.m_maxValidityPeriod, time::seconds(86400));
-  BOOST_CHECK(!config.m_caItem.m_maxSuffixLength);
+  BOOST_CHECK(!config.m_caItem.m_maxSuffixLength.has_value());
   BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.size(), 0);
   BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.size(), 2);
   BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.front(), "pin");
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index fc074a0..0807edc 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -190,7 +190,7 @@
 static void
 InfoCb(const Data& reply, const Name& certFullName)
 {
-  boost::optional<CaProfile> profile;
+  optional<CaProfile> profile;
   try {
     if (certFullName.empty()) {
       profile = Requester::onCaProfileResponse(reply);