37 #include "signer/keys.h" 39 #include <libxml/parser.h> 40 #include <libxml/xpath.h> 41 #include <libxml/xpathInternals.h> 42 #include <libxml/xmlreader.h> 45 static const char* parser_str =
"parser";
56 xmlXPathContextPtr xpathCtx = NULL;
57 xmlXPathObjectPtr xpathObj = NULL;
58 xmlNode* curNode = NULL;
59 xmlChar* xexpr = NULL;
60 key_type* new_key = NULL;
61 keylist_type* kl = NULL;
64 char* algorithm = NULL;
65 int ksk, zsk, publish, i;
68 ods_log_error(
"[%s] could not parse <Keys>, no cfgfile given",
72 ods_log_assert(cfgfile);
75 doc = xmlParseFile(cfgfile);
77 ods_log_error(
"[%s] could not parse <Keys>, xmlParseFile failed",
82 xpathCtx = xmlXPathNewContext(doc);
83 if(xpathCtx == NULL) {
85 ods_log_error(
"[%s] could not parse <Keys>, xmlXPathNewContext failed",
90 xexpr = (xmlChar*)
"//SignerConfiguration/Zone/Keys/Key";
91 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
92 if(xpathObj == NULL) {
93 xmlXPathFreeContext(xpathCtx);
95 ods_log_error(
"[%s] could not parse <Keys>, xmlXPathEvalExpression " 96 "failed", parser_str);
100 kl = keylist_create(allocator);
101 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
102 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
110 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
112 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Locator")) {
113 locator = (
char *) xmlNodeGetContent(curNode);
114 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Algorithm")) {
115 algorithm = (
char *) xmlNodeGetContent(curNode);
116 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Flags")) {
117 flags = (
char *) xmlNodeGetContent(curNode);
118 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"KSK")) {
120 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"ZSK")) {
122 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Publish")) {
125 curNode = curNode->next;
127 if (locator && algorithm && flags) {
128 new_key = key_create(allocator, locator,
129 (uint8_t) atoi(algorithm), (uint32_t) atoi(flags),
131 if (keylist_push(kl, new_key) != ODS_STATUS_OK) {
133 parser_str, locator);
136 ods_log_error(
"[%s] Key missing required elements, skipping",
139 free((
void*)locator);
140 free((
void*)algorithm);
145 xmlXPathFreeObject(xpathObj);
146 xmlXPathFreeContext(xpathCtx);
161 duration_type* duration = NULL;
163 "//SignerConfiguration/Zone/Signatures/Resign",
168 duration = duration_create_from_string(str);
177 duration_type* duration = NULL;
179 "//SignerConfiguration/Zone/Signatures/Refresh",
184 duration = duration_create_from_string(str);
193 duration_type* duration = NULL;
195 "//SignerConfiguration/Zone/Signatures/Validity/Default",
200 duration = duration_create_from_string(str);
209 duration_type* duration = NULL;
211 "//SignerConfiguration/Zone/Signatures/Validity/Denial",
216 duration = duration_create_from_string(str);
225 duration_type* duration = NULL;
227 "//SignerConfiguration/Zone/Signatures/Jitter",
232 duration = duration_create_from_string(str);
241 duration_type* duration = NULL;
243 "//SignerConfiguration/Zone/Signatures/InceptionOffset",
248 duration = duration_create_from_string(str);
257 duration_type* duration = NULL;
259 "//SignerConfiguration/Zone/Keys/TTL",
264 duration = duration_create_from_string(str);
273 duration_type* duration = NULL;
275 "//SignerConfiguration/Zone/SOA/TTL",
280 duration = duration_create_from_string(str);
289 duration_type* duration = NULL;
291 "//SignerConfiguration/Zone/SOA/Minimum",
296 duration = duration_create_from_string(str);
310 "//SignerConfiguration/Zone/Denial/NSEC3",
314 return LDNS_RR_TYPE_NSEC3;
318 "//SignerConfiguration/Zone/Denial/NSEC",
322 return LDNS_RR_TYPE_NSEC;
325 return LDNS_RR_TYPE_FIRST;
338 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Algorithm",
341 if (strlen(str) > 0) {
355 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Iterations",
358 if (strlen(str) > 0) {
376 "//SignerConfiguration/Zone/Keys/TTL",
379 if (strlen(str) > 0) {
393 "//SignerConfiguration/Zone/SOA/TTL",
396 if (strlen(str) > 0) {
410 "//SignerConfiguration/Zone/SOA/Minimum",
413 if (strlen(str) > 0) {
427 "//SignerConfiguration/Zone/Denial/NSEC3/OptOut",
442 "//SignerConfiguration/Zone/Audit",
459 const char* dup = NULL;
462 "//SignerConfiguration/Zone/SOA/Serial",
466 dup = allocator_strdup(allocator, str);
476 const char* dup = NULL;
479 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Salt",
483 dup = allocator_strdup(allocator, str);
duration_type * parse_sc_sig_validity_default(const char *cfgfile)
duration_type * parse_sc_sig_validity_denial(const char *cfgfile)
uint32_t parse_sc_nsec3_algorithm(const char *cfgfile)
duration_type * parse_sc_soa_ttl(const char *cfgfile)
const char * parse_sc_soa_serial(allocator_type *allocator, const char *cfgfile)
void ods_log_error(const char *format,...)
duration_type * parse_sc_sig_inception_offset(const char *cfgfile)
keylist_type * parse_sc_keys(allocator_type *allocator, const char *cfgfile)
const char * parse_sc_nsec3_salt(allocator_type *allocator, const char *cfgfile)
duration_type * parse_sc_dnskey_ttl(const char *cfgfile)
duration_type * parse_sc_sig_jitter(const char *cfgfile)
duration_type * parse_sc_sig_refresh_interval(const char *cfgfile)
int parse_sc_soa_ttl_use(const char *cfgfile)
int parse_sc_nsec3_optout(const char *cfgfile)
duration_type * parse_sc_soa_min(const char *cfgfile)
const char * parse_conf_string(const char *cfgfile, const char *expr, int required)
int parse_sc_soa_min_use(const char *cfgfile)
int parse_sc_dnskey_ttl_use(const char *cfgfile)
ldns_rr_type parse_sc_nsec_type(const char *cfgfile)
int parse_sc_audit(const char *cfgfile)
duration_type * parse_sc_sig_resign_interval(const char *cfgfile)
uint32_t parse_sc_nsec3_iterations(const char *cfgfile)