Kea 3.2.0-git
gss_tsig_cfg.cc
Go to the documentation of this file.
1// Copyright (C) 2021-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <dns/name.h>
10#include <gss_tsig_cfg.h>
11#include <gss_tsig_context.h>
12#include <stats/stats_mgr.h>
13
14#include <limits>
15
16using namespace isc::asiodns;
17using namespace isc::asiolink;
18using namespace isc::d2;
19using namespace isc::data;
20using namespace isc::dhcp;
21using namespace isc::stats;
22using namespace std;
23
24namespace isc {
25namespace gss_tsig {
26
28 { "id", Element::string },
29 { "domain-names", Element::list },
30 { "ip-address", Element::string },
31 { "port", Element::integer },
32 { "server-principal", Element::string },
33 { "client-principal", Element::string },
34 { "gss-replay-flag", Element::boolean },
35 { "gss-sequence-flag", Element::boolean },
36 { "tkey-lifetime", Element::integer },
37 { "rekey-interval", Element::integer },
38 { "retry-interval", Element::integer },
39 { "tkey-protocol", Element::string },
40 { "fallback", Element::boolean },
41 { "exchange-timeout", Element::integer },
42 { "user-context", Element::map },
43 { "comment", Element::string }
44};
45
46const list<string> DnsServer::STAT_NAMES = {
47 "gss-tsig-key-created",
48 "tkey-sent",
49 "tkey-success",
50 "tkey-timeout",
51 "tkey-error"
52};
53
54DnsServer::DnsServer(const string& id, const set<string>& domains,
55 const IOAddress& ip_address, uint16_t port)
56 : id_(id), domains_(domains), ip_address_(ip_address), port_(port),
57 server_infos_(), server_principal_(""), key_name_suffix_(""),
58 cred_principal_(""), gss_replay_flag_(true),
59 gss_sequence_flag_(false), tkey_lifetime_(DEFAULT_KEY_LIFETIME),
60 rekey_interval_(DEFAULT_REKEY_INTERVAL),
61 retry_interval_(DEFAULT_RETRY_INTERVAL), tkey_proto_(IOFetch::TCP),
62 fallback_(false), exchange_timeout_(DEFAULT_EXCHANGE_TIMEOUT), timer_() {
64 "DEFAULT_REKEY_INTERVAL < DEFAULT_KEY_LIFETIME");
66 "DEFAULT_RETRY_INTERVAL < DEFAULT_REKEY_INTERVAL");
67 initStats();
68}
69
71 removeStats();
72}
73
74void
75DnsServer::initStats() {
76 StatsMgr& stats_mgr = StatsMgr::instance();
77 for (auto const& name : DnsServer::STAT_NAMES) {
78 const string& sname = StatsMgr::generateName("server", id_, name);
79 stats_mgr.setValue(sname, static_cast<int64_t>(0));
80 }
81}
82
83void
84DnsServer::removeStats() {
85 StatsMgr& stats_mgr = StatsMgr::instance();
86 for (auto const& name : DnsServer::STAT_NAMES) {
87 const string& sname = StatsMgr::generateName("server", id_, name);
88 stats_mgr.del(sname);
89 }
90}
91
92void
94 StatsMgr& stats_mgr = StatsMgr::instance();
95 for (auto const& name : DnsServer::STAT_NAMES) {
96 const string& sname = StatsMgr::generateName("server", id_, name);
97 stats_mgr.reset(sname);
98 }
99}
100
101void
103 string suffix = server_principal_;
104 size_t pos = suffix.find_first_of("/");
105 if (pos != string::npos) {
106 suffix = suffix.substr(pos + 1);
107 }
108 pos = suffix.find_last_of("@");
109 if (pos != string::npos) {
110 suffix = suffix.substr(0, pos);
111 }
112 if (suffix.empty()) {
113 isc_throw(BadValue, "can't get the GSS-TSIG key name suffix from "
114 << "the DNS server principal '" << server_principal_
115 << "'");
116 }
117 key_name_suffix_ = string("sig-") + suffix;
119}
120
121void
123 // 32 bits mean at most 10 digits
124 string tname = "1234567890." + key_name_suffix_;
125 try {
126 dns::Name dname(tname);
127 string nname = dname.toText();
128 size_t pos = nname.find_first_of(".");
129 if (pos != 10) {
130 isc_throw(Unexpected, "string to FQDN failed (dot at "
131 << pos << " instead 10)");
132 }
133 key_name_suffix_ = nname.substr(pos + 1);
134 } catch (const std::exception& ex) {
135 isc_throw(BadValue, "check of the GSS-TSIG key name suffix '"
136 << key_name_suffix_ << "' failed: " << ex.what());
137 }
138}
139
140void
142 if (!d2_config) {
143 isc_throw(D2CfgError, "empty D2 config");
144 }
145 if (!server_infos_.empty()) {
146 isc_throw(D2CfgError, "server info list is not empty");
147 }
148 set<string> seen;
149 DdnsDomainListMgrPtr d2_dom_mgr = d2_config->getForwardMgr();
150 DdnsDomainMapPtr d2_dom_map;
151 if (d2_dom_mgr) {
152 d2_dom_map = d2_dom_mgr->getDomains();
153 }
154 if (d2_dom_map) {
155 for (auto const& it : *d2_dom_map) {
156 if (!domains_.empty()) {
157 if (domains_.count(it.first) == 0) {
158 continue;
159 }
160 static_cast<void>(seen.insert(it.first));
161 }
162 buildServerInfo(it.second);
163 }
164 }
165 d2_dom_mgr = d2_config->getReverseMgr();
166 if (d2_dom_mgr) {
167 d2_dom_map = d2_dom_mgr->getDomains();
168 } else {
169 d2_dom_map = DdnsDomainMapPtr();
170 }
171 if (d2_dom_map) {
172 for (auto const& it : *d2_dom_map) {
173 if (!domains_.empty()) {
174 if (domains_.count(it.first) == 0) {
175 continue;
176 }
177 static_cast<void>(seen.insert(it.first));
178 }
179 buildServerInfo(it.second);
180 }
181 }
182 if (getServerInfos().empty()) {
183 isc_throw(NotFound, "server info can't be found");
184 }
185 if (!domains_.empty()) {
186 for (auto const& domain : domains_) {
187 if (seen.count(domain) == 0) {
188 isc_throw(NotFound, "domain '" << domain << "' can't be found");
189 }
190 }
191 }
192}
193
194void
196 if (!d2_dns_domain) {
197 return;
198 }
199 DnsServerInfoStoragePtr servers = d2_dns_domain->getServers();
200 if (!servers) {
201 return;
202 }
203 for (auto const& info : *servers) {
204 if (!info) {
205 continue;
206 }
207 if (!info->isEnabled()) {
208 continue;
209 }
210 if (info->getIpAddress() != getIpAddress()) {
211 continue;
212 }
213 if (info->getPort() != getPort()) {
214 continue;
215 }
217 }
218}
219
223
224 // Add user-context.
225 contextToElement(map);
226
227 // ID..
228 map->set("id", Element::create(getID()));
229
230 // Domains.
231 if (!domains_.empty()) {
233 for (auto const& domain : domains_) {
234 domains->add(Element::create(domain));
235 }
236 map->set("domain-names", domains);
237 }
238
239 // IP address.
240 map->set("ip-address", Element::create(ip_address_.toText()));
241
242 // Port.
243 map->set("port", Element::create(static_cast<int>(port_)));
244
245 // Server principal.
246 map->set("server-principal", Element::create(server_principal_));
247
248 // GSS-TSIG key name suffix.
249 map->set("key-name-suffix", Element::create(key_name_suffix_));
250
251 // Client principal.
252 if (!cred_principal_.empty()) {
253 map->set("client-principal", Element::create(cred_principal_));
254 }
255
256 // GSS (anti) replay flag.
257 map->set("gss-replay-flag", Element::create(gss_replay_flag_));
258
259 // GSS sequence flag.
260 map->set("gss-sequence-flag", Element::create(gss_sequence_flag_));
261
262 // TKEY lifetime.
263 map->set("tkey-lifetime",
264 Element::create(static_cast<long long>(tkey_lifetime_)));
265
266 // Rekey interval.
267 map->set("rekey-interval",
268 Element::create(static_cast<long long>(rekey_interval_)));
269
270 // Retry interval.
271 map->set("retry-interval",
272 Element::create(static_cast<long long>(retry_interval_)));
273
274 // TKEY protocol.
275 string proto = (tkey_proto_ == IOFetch::TCP ? "TCP" : "UDP");
276 map->set("tkey-protocol", Element::create(proto));
277
278 // Fallback.
279 map->set("fallback", Element::create(fallback_));
280
281 // TKEY exchange timeout.
282 map->set("exchange-timeout",
283 Element::create(static_cast<long long>(exchange_timeout_)));
284
285 return (map);
286}
287
289 { "server-principal", Element::string },
290 { "client-principal", Element::string },
291 { "client-keytab", Element::string },
292 { "credentials-cache", Element::string },
293 { "gss-replay-flag", Element::boolean },
294 { "gss-sequence-flag", Element::boolean },
295 { "tkey-lifetime", Element::integer },
296 { "rekey-interval", Element::integer },
297 { "retry-interval", Element::integer },
298 { "tkey-protocol", Element::string },
299 { "fallback", Element::boolean },
300 { "exchange-timeout", Element::integer },
301 { "ignore-bad-direction", Element::boolean },
302 { "servers", Element::list },
303 { "user-context", Element::map },
304 { "comment", Element::string }
305};
306
308 : servers_(), servers_rev_map_(), client_keytab_(""), creds_cache_(""),
309 max_tkey_lifetime_(0), ignore_bad_direction_(false) {
310}
311
314
317 auto candidate = servers_rev_map_.find(server_info);
318 if (candidate == servers_rev_map_.end()) {
319 return (DnsServerPtr());
320 }
321 return (candidate->second);
322}
323
325GssTsigCfg::getServer(const string& id) const {
326 auto const& index = servers_.template get<DnsServerIdTag>();
327 auto const it = index.find(id);
328 if (it == index.cend()) {
329 return (DnsServerPtr());
330 }
331 return (*it);
332}
333
334void
336 if (!servers_rev_map_.empty()) {
337 isc_throw(D2CfgError, "server reverse map is not empty");
338 }
339 for (auto const& server : getServerList()) {
340 server->buildServerInfo(d2_config);
341 for (auto const& info : server->getServerInfos()) {
342 if (servers_rev_map_.count(info) > 0) {
343 isc_throw(D2CfgError, "duplicate");
344 }
345 servers_rev_map_[info] = server;
346 }
347 }
348}
349
350void
352 if (!params) {
353 isc_throw(BadValue, "gss_tsig parameters entry is mandatory");
354 }
355 if (params->getType() != Element::map) {
356 isc_throw(BadValue, "gss_tsig parameters entry must be a map");
357 }
358 try {
360 } catch(const DhcpConfigError& ex) {
361 isc_throw(BadValue, "gss_tsig " << ex.what() << " ("
362 << params->getPosition() << ")");
363 }
364
365 ConstElementPtr client_keytab = params->get("client-keytab");
366 if (client_keytab) {
367 setClientKeyTab(client_keytab->stringValue());
368 }
369
370 ConstElementPtr credentials_cache = params->get("credentials-cache");
371 if (credentials_cache) {
372 setCredsCache(credentials_cache->stringValue());
373 }
374
375 string retry_interval_origin = "default";
376 string retry_interval_location = "";
377 int64_t global_retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
378 ConstElementPtr global_retry_interval = params->get("retry-interval");
379 if (global_retry_interval) {
380 retry_interval_origin = "global";
381 retry_interval_location += " (";
382 retry_interval_location += global_retry_interval->getPosition().str();
383 retry_interval_location += ")";
384 global_retry_val = global_retry_interval->intValue();
385 if ((global_retry_val < 0) ||
386 (global_retry_val > numeric_limits<uint32_t>::max())) {
387 isc_throw(BadValue, "'retry-interval' parameter is out of "
388 "range [0.." << numeric_limits<uint32_t>::max()
389 << "]" << retry_interval_location);
390 }
391 }
392
393 string rekey_interval_origin = "default";
394 string rekey_interval_location = "";
395 int64_t global_rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
396 ConstElementPtr global_rekey_interval = params->get("rekey-interval");
397 if (global_rekey_interval) {
398 rekey_interval_origin = "global";
399 rekey_interval_location += " (";
400 rekey_interval_location += global_rekey_interval->getPosition().str();
401 rekey_interval_location += ")";
402 global_rekey_val = global_rekey_interval->intValue();
403 if ((global_rekey_val < 0) ||
404 (global_rekey_val > numeric_limits<uint32_t>::max())) {
405 isc_throw(BadValue, "'rekey-interval' parameter is out of "
406 "range [0.." << numeric_limits<uint32_t>::max()
407 << "]" << rekey_interval_location);
408 }
409 }
410
411 string tkey_lifetime_origin = "default";
412 string tkey_lifetime_location = "";
413 int64_t global_tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
414 ConstElementPtr global_tkey_lifetime = params->get("tkey-lifetime");
415 if (global_tkey_lifetime) {
416 tkey_lifetime_origin = "global";
417 tkey_lifetime_location += " (";
418 tkey_lifetime_location += global_tkey_lifetime->getPosition().str();
419 tkey_lifetime_location += ")";
420 global_tkey_lifetime_val = global_tkey_lifetime->intValue();
421 if ((global_tkey_lifetime_val < 0) ||
422 (global_tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
423 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
424 "range [0.." << numeric_limits<uint32_t>::max()
425 << "]" << tkey_lifetime_location);
426 }
427 }
428
429 if (global_retry_val >= global_rekey_val) {
430 isc_throw(BadValue, "the " << retry_interval_origin
431 << " 'retry-interval' parameter"
432 << retry_interval_location << " must be smaller then the "
433 << rekey_interval_origin << " 'rekey-interval' parameter"
434 << retry_interval_location << ": range [0.."
435 << global_rekey_val << "]");
436 }
437
438 if (global_rekey_val >= global_tkey_lifetime_val) {
439 isc_throw(BadValue, "the " << rekey_interval_origin
440 << " 'rekey-interval' parameter"
441 << rekey_interval_location << " must be smaller than the "
442 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
443 << tkey_lifetime_location << ": range [0.."
444 << global_tkey_lifetime_val << "]");
445 }
446
447 ConstElementPtr global_tkey_proto = params->get("tkey-protocol");
448 if (global_tkey_proto) {
449 string val = global_tkey_proto->stringValue();
450 if ((val != "UDP") && (val != "TCP")) {
451 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
452 "or TCP (" << global_tkey_proto->getPosition() << ")");
453 }
454 }
455
456 ConstElementPtr global_fallback = params->get("fallback");
457
458 ConstElementPtr global_tkey_timeout = params->get("exchange-timeout");
459 if (global_tkey_timeout) {
460 int64_t val = global_tkey_timeout->intValue();
461 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
462 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
463 "range [0.." << numeric_limits<uint32_t>::max()
464 << "] (" << global_tkey_timeout->getPosition() << ")");
465 }
466 }
467
468 ConstElementPtr ignore_bad_direction = params->get("ignore-bad-direction");
469 if (ignore_bad_direction) {
470 bool val = ignore_bad_direction->boolValue();
471 ignore_bad_direction_ = val;
473 }
474
475 ConstElementPtr servers = params->get("servers");
476 if (!servers) {
477 return;
478 }
479
480 uint32_t max_tkey_lifetime = 0;
481 for (auto const& map : servers->listValue()) {
482 if (!map) {
483 continue;
484 }
485 if (map->getType() != Element::map) {
486 isc_throw(BadValue, "'servers' parameter must be a list of "
487 "maps (" << map->getPosition() << ")");
488 }
489 try {
491 } catch (const DhcpConfigError& ex) {
492 isc_throw(BadValue, "gss_tsig server " << ex.what() << " ("
493 << map->getPosition() << ")");
494 }
495
496 ConstElementPtr id_elem = map->get("id");
497 if (!id_elem) {
498 isc_throw(BadValue, "'id' parameter is required in "
499 "gss_tsig server entry (" << map->getPosition() << ")");
500 }
501 const string& id = id_elem->stringValue();
502 if (id.empty()) {
503 isc_throw(BadValue, "'id' parameter must be not empty in "
504 "gss_tsig server entry (" << map->getPosition() << ")");
505 }
506 if (getServer(id)) {
507 isc_throw(BadValue, "'" << id << "' id is already used in "
508 "gss_tsig server entry (" << map->getPosition() << ")");
509 }
510
511 ConstElementPtr domains_list = map->get("domain-names");
512 set<string> domains;
513 if (domains_list && !domains_list->empty()) {
514 for (auto const& domain : domains_list->listValue()) {
515 if (!domain) {
516 continue;
517 }
518 if (domain->getType() != Element::string) {
519 isc_throw(BadValue, "gss_tsig server 'domain-names' list "
520 << "must contain only strings ("
521 << domain->getPosition() << ")");
522 }
523 // Ignore duplicates.
524 static_cast<void>(domains.insert(domain->stringValue()));
525 }
526 }
527
528 DnsServerPtr srv;
529 ConstElementPtr ip_address = map->get("ip-address");
530 if (!ip_address) {
531 isc_throw(BadValue, "'ip-address' parameter is required in "
532 "gss_tsig server entry (" << map->getPosition() << ")");
533 }
534 try {
535 IOAddress addr(ip_address->stringValue());
536 if (map->contains("port")) {
537 int64_t port(SimpleParser::getInteger(map, "port", 0,
538 numeric_limits<uint16_t>::max()));
539 srv.reset(new DnsServer(id, domains, addr,
540 static_cast<uint16_t>(port)));
541 } else {
542 srv.reset(new DnsServer(id, domains, addr));
543 }
544 } catch (const DhcpConfigError& ex) {
545 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what());
546 } catch (const std::exception& ex) {
547 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
548 << " (" << map->getPosition() << ")");
549 }
550
551 ConstElementPtr server_principal = map->get("server-principal");
552 bool server_principal_global = false;
553 if (!server_principal) {
554 server_principal = params->get("server-principal");
555 server_principal_global = true;
556 }
557 if (!server_principal) {
558 isc_throw(BadValue, "'server-principal' parameter is required in "
559 "gss_tsig server entry (" << map->getPosition() << ")");
560 }
561 srv->setServerPrincipal(server_principal->stringValue());
562 try {
563 srv->buildKeyNameSuffix();
564 } catch (const std::exception& ex) {
565 if (server_principal_global) {
566 isc_throw(BadValue, "gss_tsig bad server-principal parameter: "
567 << ex.what() << " ("
568 << server_principal->getPosition() << ")");
569 } else {
570 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
571 << " (" << server_principal->getPosition() << ")");
572 }
573 }
574
575 ConstElementPtr gss_replay_flag = map->get("gss-replay-flag");
576 if (!gss_replay_flag) {
577 gss_replay_flag = params->get("gss-replay-flag");
578 }
579 if (gss_replay_flag) {
580 srv->setGssReplayFlag(gss_replay_flag->boolValue());
581 }
582
583 ConstElementPtr gss_sequence_flag = map->get("gss-sequence-flag");
584 if (!gss_sequence_flag) {
585 gss_sequence_flag = params->get("gss-sequence-flag");
586 }
587 if (gss_sequence_flag) {
588 srv->setGssSequenceFlag(gss_sequence_flag->boolValue());
589 }
590
591 ConstElementPtr cred_principal = map->get("client-principal");
592 if (!cred_principal) {
593 cred_principal = params->get("client-principal");
594 }
595 if (cred_principal) {
596 srv->setClientPrincipal(cred_principal->stringValue());
597 }
598
599 retry_interval_location = "";
600 ConstElementPtr retry_interval = map->get("retry-interval");
601 if (!retry_interval) {
602 retry_interval = global_retry_interval;
603 } else {
604 retry_interval_origin = "server";
605 }
606 int64_t retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
607 if (retry_interval) {
608 retry_interval_location += " (";
609 retry_interval_location += retry_interval->getPosition().str();
610 retry_interval_location += ")";
611 retry_val = retry_interval->intValue();
612 if ((retry_val < 0) ||
613 (retry_val > numeric_limits<uint32_t>::max())) {
614 isc_throw(BadValue, "'retry-interval' parameter is out of "
615 "range [0.." << numeric_limits<uint32_t>::max()
616 << "]" << retry_interval_location);
617 }
618 srv->setRetryInterval(retry_val);
619 }
620
621 rekey_interval_location = "";
622 ConstElementPtr rekey_interval = map->get("rekey-interval");
623 if (!rekey_interval) {
624 rekey_interval = global_rekey_interval;
625 } else {
626 rekey_interval_origin = "server";
627 }
628 int64_t rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
629 if (rekey_interval) {
630 rekey_interval_location += " (";
631 rekey_interval_location += rekey_interval->getPosition().str();
632 rekey_interval_location += ")";
633 rekey_val = rekey_interval->intValue();
634 if ((rekey_val < 0) ||
635 (rekey_val > numeric_limits<uint32_t>::max())) {
636 isc_throw(BadValue, "'rekey-interval' parameter is out of "
637 "range [0.." << numeric_limits<uint32_t>::max()
638 << "]" << rekey_interval_location);
639 }
640 srv->setRekeyInterval(rekey_val);
641 }
642
643 tkey_lifetime_location = "";
644 ConstElementPtr tkey_lifetime = map->get("tkey-lifetime");
645 if (!tkey_lifetime) {
646 tkey_lifetime = global_tkey_lifetime;
647 } else {
648 tkey_lifetime_origin = "server";
649 }
650 int64_t tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
651 if (tkey_lifetime) {
652 tkey_lifetime_location += " (";
653 tkey_lifetime_location += tkey_lifetime->getPosition().str();
654 tkey_lifetime_location += ")";
655 tkey_lifetime_val = tkey_lifetime->intValue();
656 if ((tkey_lifetime_val < 0) ||
657 (tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
658 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
659 "range [0.." << numeric_limits<uint32_t>::max()
660 << "]" << tkey_lifetime_location);
661 }
662 srv->setKeyLifetime(tkey_lifetime_val);
663 }
664 if (tkey_lifetime_val > max_tkey_lifetime) {
665 max_tkey_lifetime = tkey_lifetime_val;
666 }
667
668 if (retry_val >= rekey_val) {
669 isc_throw(BadValue, "the " << retry_interval_origin
670 << " 'retry-interval' parameter"
671 << retry_interval_location << " must be smaller then the "
672 << rekey_interval_origin << " 'rekey-interval' parameter"
673 << retry_interval_location << ": range [0.."
674 << rekey_val << "]");
675 }
676
677 if (rekey_val >= tkey_lifetime_val) {
678 isc_throw(BadValue, "the " << rekey_interval_origin
679 << " 'rekey-interval' parameter"
680 << rekey_interval_location << " must be smaller than the "
681 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
682 << tkey_lifetime_location << ": range [0.."
683 << tkey_lifetime_val << "]");
684 }
685
686 ConstElementPtr tkey_proto = map->get("tkey-protocol");
687 if (!tkey_proto) {
688 tkey_proto = global_tkey_proto;
689 }
690 if (tkey_proto) {
691 string val = tkey_proto->stringValue();
692 if (val == "UDP") {
693 srv->setKeyProto(IOFetch::UDP);
694 } else if (val == "TCP") {
695 srv->setKeyProto(IOFetch::TCP);
696 } else {
697 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
698 "or TCP (" << tkey_proto->getPosition() << ")");
699 }
700 }
701
702 ConstElementPtr fallback = map->get("fallback");
703 if (!fallback) {
704 fallback = global_fallback;
705 }
706 if (fallback) {
707 srv->setFallback(fallback->boolValue());
708 }
709
710 ConstElementPtr tkey_timeout = map->get("exchange-timeout");
711 if (!tkey_timeout) {
712 tkey_timeout = global_tkey_timeout;
713 }
714 if (tkey_timeout) {
715 int64_t val = tkey_timeout->intValue();
716 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
717 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
718 "range [0.." << numeric_limits<uint32_t>::max()
719 << "] (" << tkey_timeout->getPosition() << ")");
720 }
721 srv->setExchangeTimeout(val);
722 }
723
724 addServer(srv);
725 }
726 setMaxKeyLifetime(max_tkey_lifetime);
727}
728
729} // end of namespace isc::gss_tsig
730} // end of namespace isc
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
Definition data.cc:299
@ map
Definition data.h:160
@ integer
Definition data.h:153
@ boolean
Definition data.h:155
@ list
Definition data.h:159
@ string
Definition data.h:157
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when an object can not be found.
A generic exception that is thrown when an unexpected error condition occurs.
Upstream Fetch Processing.
Definition io_fetch.h:34
Exception thrown when the error during configuration handling occurs.
Definition d2_config.h:136
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
To be removed. Please use ConfigError instead.
The Name class encapsulates DNS names.
Definition name.h:219
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:503
GSS-TSIG hook configuration for a server.
static const std::list< std::string > STAT_NAMES
Server TKEY exchange statistics names.
void checkKeyNameSuffix()
Check and fix the GSS-TSIG key name suffix.
static const isc::data::SimpleKeywords SERVER_PARAMETERS
This table defines all server parameters.
virtual void resetStats()
Reset statistics.
uint16_t getPort() const
Get the server port.
virtual ~DnsServer()
Destructor.
const isc::d2::DnsServerInfoStorage & getServerInfos() const
Get the server info list.
DnsServer(const std::string &id, const std::set< std::string > &domains, const isc::asiolink::IOAddress &ip_address, uint16_t port=isc::d2::DnsServerInfo::STANDARD_DNS_PORT)
Constructor.
void buildKeyNameSuffix()
Build the GSS-TSIG key name suffix.
std::string getID() const
Get the ID.
void addServerInfo(isc::d2::DnsServerInfoPtr server_info)
Add a server info to the list.
static constexpr size_t DEFAULT_REKEY_INTERVAL
The rekey timer interval (expressed in seconds).
isc::data::ElementPtr toElement() const
Unparse a DNS server object.
const isc::asiolink::IOAddress & getIpAddress() const
Get the server IP address.
static constexpr size_t DEFAULT_KEY_LIFETIME
The default TKEY lifetime (expressed in seconds).
static constexpr size_t DEFAULT_EXCHANGE_TIMEOUT
The default TKEY exchange timeout (expressed in milliseconds).
static constexpr size_t DEFAULT_RETRY_INTERVAL
The retry timer interval (expressed in seconds).
void buildServerInfo(isc::d2::D2CfgContextPtr d2_config)
Convert the list of DNS domains to the server info list.
static bool ignore_bad_direction_
Ignore bad direction flag.
const DnsServerList & getServerList() const
Get the DNS server list.
virtual ~GssTsigCfg()
Destructor.
DnsServerPtr getServer(const isc::d2::DnsServerInfoPtr &server_info) const
Get the DNS server from a server info.
void setClientKeyTab(const std::string &client_keytab)
Set the client key table specification.
void setCredsCache(const std::string &creds_cache)
Set the credentials cache specification.
void buildServerRevMap(isc::d2::D2CfgContextPtr d2_config)
Build the reverse map.
void configure(isc::data::ConstElementPtr params)
Configure.
static const isc::data::SimpleKeywords GLOBAL_PARAMETERS
This table defines all global parameters.
void setMaxKeyLifetime(uint32_t max_tkey_lifetime)
Set the maximum TKEY lifetime.
void addServer(DnsServerPtr server)
Add a DNS server to the list.
Statistics Manager class.
static StatsMgr & instance()
Statistics Manager accessor method.
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
bool reset(const std::string &name)
Resets specified statistic.
bool del(const std::string &name)
Removes specified statistic.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
int get(CalloutHandle &handle)
The gss-tsig-get command.
Implements a TSIGContext derived class which can be used as the value of TSIGContext pointers so with...
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
Definition d2_cfg_mgr.h:175
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition d2_config.h:624
boost::shared_ptr< DdnsDomainMap > DdnsDomainMapPtr
Defines a pointer to DdnsDomain storage containers.
Definition d2_config.h:633
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
Definition d2_cfg_mgr.h:26
boost::shared_ptr< DnsServerInfoStorage > DnsServerInfoStoragePtr
Defines a pointer to DnsServerInfo storage containers.
Definition d2_config.h:560
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
@ info
Definition db_log.h:126
boost::shared_ptr< DnsServer > DnsServerPtr
A pointer to a DNS server.
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.