TLV encoding to replace JSON format message
diff --git a/src/client-config.cpp b/src/client-config.cpp
index 9273760..47115bb 100644
--- a/src/client-config.cpp
+++ b/src/client-config.cpp
@@ -84,21 +84,17 @@
}
ClientCaItem
-ClientConfig::extractCaItem(const Block& contentBlock)
+ClientConfig::extractCaItem(const JsonSection& configSection)
{
ClientCaItem item;
- item.m_caName = Name(readString(contentBlock.get(CAPrefix)));
+ item.m_caName = Name(configSection.get("ca-prefix", ""));
if (item.m_caName.empty()) {
BOOST_THROW_EXCEPTION(Error("Cannot read ca-prefix from the config file"));
}
- item.m_caInfo = readString(contentBlock.get(CAInfo));
- // item.m_probe = configSection.get("probe", "");
-
- security::v2::Certificate anchor = contentBlock.get(CACertificate);
-
- //std::istringstream ss(configSection.get("certificate", ""));
- //auto anchor = io::load<security::v2::Certificate>(ss);
-
+ item.m_caInfo = configSection.get("ca-info", "");
+ item.m_probe = configSection.get("probe", "");
+ std::istringstream ss(configSection.get("certificate", ""));
+ auto anchor = io::load<security::v2::Certificate>(ss);
if (anchor == nullptr) {
BOOST_THROW_EXCEPTION(Error("Cannot load the certificate from config file"));
}
@@ -106,6 +102,28 @@
return item;
}
+ClientCaItem
+ClientConfig::extractCaItem(const Block& contentBlock)
+{
+ ClientCaItem item;
+ item.m_caName = Name(readString(contentBlock.get(tlv_ca_prefix)));
+ if (item.m_caName.empty()) {
+ BOOST_THROW_EXCEPTION(Error("Cannot read ca-prefix from the config file"));
+ }
+ item.m_caInfo = readString(contentBlock.get(tlv_ca_info));
+ // item.m_probe = configSection.get("probe", "");
+
+ if (!contentBlock.get(tlv_ca_certificate).hasValue()) {
+ BOOST_THROW_EXCEPTION(Error("Cannot load the certificate from config file"));
+ }
+
+ security::v2::Certificate anchor;
+ anchor.wireDecode(contentBlock.get(tlv_ca_certificate));
+ item.m_anchor = anchor;
+
+ return item;
+}
+
void
ClientConfig::removeCaItem(const Name& caName)
{