Kea 3.0.3-git
gss_tsig_cfg.cc
Go to the documentation of this file.
1// Copyright (C) 2021-2025 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 <stats/stats_mgr.h>
12
13#include <limits>
14
15using namespace isc::asiodns;
16using namespace isc::asiolink;
17using namespace isc::d2;
18using namespace isc::data;
19using namespace isc::dhcp;
20using namespace isc::stats;
21using namespace std;
22
23namespace isc {
24namespace gss_tsig {
25
27 { "id", Element::string },
28 { "domain-names", Element::list },
29 { "ip-address", Element::string },
30 { "port", Element::integer },
31 { "server-principal", Element::string },
32 { "client-principal", Element::string },
33 { "gss-replay-flag", Element::boolean },
34 { "gss-sequence-flag", Element::boolean },
35 { "tkey-lifetime", Element::integer },
36 { "rekey-interval", Element::integer },
37 { "retry-interval", Element::integer },
38 { "tkey-protocol", Element::string },
39 { "fallback", Element::boolean },
40 { "exchange-timeout", Element::integer },
41 { "user-context", Element::map },
42 { "comment", Element::string }
43};
44
45const list<string> DnsServer::STAT_NAMES = {
46 "gss-tsig-key-created",
47 "tkey-sent",
48 "tkey-success",
49 "tkey-timeout",
50 "tkey-error"
51};
52
53DnsServer::DnsServer(const string& id, const set<string>& domains,
54 const IOAddress& ip_address, uint16_t port)
55 : id_(id), domains_(domains), ip_address_(ip_address), port_(port),
56 server_infos_(), server_principal_(""), key_name_suffix_(""),
57 cred_principal_(""), gss_replay_flag_(true),
58 gss_sequence_flag_(false), tkey_lifetime_(DEFAULT_KEY_LIFETIME),
59 rekey_interval_(DEFAULT_REKEY_INTERVAL),
60 retry_interval_(DEFAULT_RETRY_INTERVAL), tkey_proto_(IOFetch::TCP),
61 fallback_(false), exchange_timeout_(DEFAULT_EXCHANGE_TIMEOUT), timer_() {
63 "DEFAULT_REKEY_INTERVAL < DEFAULT_KEY_LIFETIME");
65 "DEFAULT_RETRY_INTERVAL < DEFAULT_REKEY_INTERVAL");
66 initStats();
67}
68
70 removeStats();
71}
72
73void
74DnsServer::initStats() {
75 StatsMgr& stats_mgr = StatsMgr::instance();
76 for (auto const& name : DnsServer::STAT_NAMES) {
77 const string& sname = StatsMgr::generateName("server", id_, name);
78 stats_mgr.setValue(sname, static_cast<int64_t>(0));
79 }
80}
81
82void
83DnsServer::removeStats() {
84 StatsMgr& stats_mgr = StatsMgr::instance();
85 for (auto const& name : DnsServer::STAT_NAMES) {
86 const string& sname = StatsMgr::generateName("server", id_, name);
87 stats_mgr.del(sname);
88 }
89}
90
91void
93 StatsMgr& stats_mgr = StatsMgr::instance();
94 for (auto const& name : DnsServer::STAT_NAMES) {
95 const string& sname = StatsMgr::generateName("server", id_, name);
96 stats_mgr.reset(sname);
97 }
98}
99
100void
102 string suffix = server_principal_;
103 size_t pos = suffix.find_first_of("/");
104 if (pos != string::npos) {
105 suffix = suffix.substr(pos + 1);
106 }
107 pos = suffix.find_last_of("@");
108 if (pos != string::npos) {
109 suffix = suffix.substr(0, pos);
110 }
111 if (suffix.empty()) {
112 isc_throw(BadValue, "can't get the GSS-TSIG key name suffix from "
113 << "the DNS server principal '" << server_principal_
114 << "'");
115 }
116 key_name_suffix_ = string("sig-") + suffix;
118}
119
120void
122 // 32 bits mean at most 10 digits
123 string tname = "1234567890." + key_name_suffix_;
124 try {
125 dns::Name dname(tname);
126 string nname = dname.toText();
127 size_t pos = nname.find_first_of(".");
128 if (pos != 10) {
129 isc_throw(Unexpected, "string to FQDN failed (dot at "
130 << pos << " instead 10)");
131 }
132 key_name_suffix_ = nname.substr(pos + 1);
133 } catch (const std::exception& ex) {
134 isc_throw(BadValue, "check of the GSS-TSIG key name suffix '"
135 << key_name_suffix_ << "' failed: " << ex.what());
136 }
137}
138
139void
141 if (!d2_config) {
142 isc_throw(D2CfgError, "empty D2 config");
143 }
144 if (!server_infos_.empty()) {
145 isc_throw(D2CfgError, "server info list is not empty");
146 }
147 set<string> seen;
148 DdnsDomainListMgrPtr d2_dom_mgr = d2_config->getForwardMgr();
149 DdnsDomainMapPtr d2_dom_map;
150 if (d2_dom_mgr) {
151 d2_dom_map = d2_dom_mgr->getDomains();
152 }
153 if (d2_dom_map) {
154 for (auto const& it : *d2_dom_map) {
155 if (!domains_.empty()) {
156 if (domains_.count(it.first) == 0) {
157 continue;
158 }
159 static_cast<void>(seen.insert(it.first));
160 }
161 buildServerInfo(it.second);
162 }
163 }
164 d2_dom_mgr = d2_config->getReverseMgr();
165 if (d2_dom_mgr) {
166 d2_dom_map = d2_dom_mgr->getDomains();
167 } else {
168 d2_dom_map = DdnsDomainMapPtr();
169 }
170 if (d2_dom_map) {
171 for (auto const& it : *d2_dom_map) {
172 if (!domains_.empty()) {
173 if (domains_.count(it.first) == 0) {
174 continue;
175 }
176 static_cast<void>(seen.insert(it.first));
177 }
178 buildServerInfo(it.second);
179 }
180 }
181 if (getServerInfos().empty()) {
182 isc_throw(NotFound, "server info can't be found");
183 }
184 if (!domains_.empty()) {
185 for (auto const& domain : domains_) {
186 if (seen.count(domain) == 0) {
187 isc_throw(NotFound, "domain '" << domain << "' can't be found");
188 }
189 }
190 }
191}
192
193void
195 if (!d2_dns_domain) {
196 return;
197 }
198 DnsServerInfoStoragePtr servers = d2_dns_domain->getServers();
199 if (!servers) {
200 return;
201 }
202 for (auto const& info : *servers) {
203 if (!info) {
204 continue;
205 }
206 if (!info->isEnabled()) {
207 continue;
208 }
209 if (info->getIpAddress() != getIpAddress()) {
210 continue;
211 }
212 if (info->getPort() != getPort()) {
213 continue;
214 }
216 }
217}
218
222
223 // Add user-context.
224 contextToElement(map);
225
226 // ID..
227 map->set("id", Element::create(getID()));
228
229 // Domains.
230 if (!domains_.empty()) {
232 for (auto const& domain : domains_) {
233 domains->add(Element::create(domain));
234 }
235 map->set("domain-names", domains);
236 }
237
238 // IP address.
239 map->set("ip-address", Element::create(ip_address_.toText()));
240
241 // Port.
242 map->set("port", Element::create(static_cast<int>(port_)));
243
244 // Server principal.
245 map->set("server-principal", Element::create(server_principal_));
246
247 // GSS-TSIG key name suffix.
248 map->set("key-name-suffix", Element::create(key_name_suffix_));
249
250 // Client principal.
251 if (!cred_principal_.empty()) {
252 map->set("client-principal", Element::create(cred_principal_));
253 }
254
255 // GSS (anti) replay flag.
256 map->set("gss-replay-flag", Element::create(gss_replay_flag_));
257
258 // GSS sequence flag.
259 map->set("gss-sequence-flag", Element::create(gss_sequence_flag_));
260
261 // TKEY lifetime.
262 map->set("tkey-lifetime",
263 Element::create(static_cast<long long>(tkey_lifetime_)));
264
265 // Rekey interval.
266 map->set("rekey-interval",
267 Element::create(static_cast<long long>(rekey_interval_)));
268
269 // Retry interval.
270 map->set("retry-interval",
271 Element::create(static_cast<long long>(retry_interval_)));
272
273 // TKEY protocol.
274 string proto = (tkey_proto_ == IOFetch::TCP ? "TCP" : "UDP");
275 map->set("tkey-protocol", Element::create(proto));
276
277 // Fallback.
278 map->set("fallback", Element::create(fallback_));
279
280 // TKEY exchange timeout.
281 map->set("exchange-timeout",
282 Element::create(static_cast<long long>(exchange_timeout_)));
283
284 return (map);
285}
286
288 { "server-principal", Element::string },
289 { "client-principal", Element::string },
290 { "client-keytab", Element::string },
291 { "credentials-cache", Element::string },
292 { "gss-replay-flag", Element::boolean },
293 { "gss-sequence-flag", Element::boolean },
294 { "tkey-lifetime", Element::integer },
295 { "rekey-interval", Element::integer },
296 { "retry-interval", Element::integer },
297 { "tkey-protocol", Element::string },
298 { "fallback", Element::boolean },
299 { "servers", Element::list },
300 { "user-context", Element::map },
301 { "comment", Element::string }
302};
303
305 : servers_(), servers_rev_map_(), client_keytab_(""), creds_cache_(""),
306 max_tkey_lifetime_(0) {
307}
308
311
314 auto candidate = servers_rev_map_.find(server_info);
315 if (candidate == servers_rev_map_.end()) {
316 return (DnsServerPtr());
317 }
318 return (candidate->second);
319}
320
322GssTsigCfg::getServer(const string& id) const {
323 auto const& index = servers_.template get<DnsServerIdTag>();
324 auto const it = index.find(id);
325 if (it == index.cend()) {
326 return (DnsServerPtr());
327 }
328 return (*it);
329}
330
331void
333 if (!servers_rev_map_.empty()) {
334 isc_throw(D2CfgError, "server reverse map is not empty");
335 }
336 for (auto const& server : getServerList()) {
337 server->buildServerInfo(d2_config);
338 for (auto const& info : server->getServerInfos()) {
339 if (servers_rev_map_.count(info) > 0) {
340 isc_throw(D2CfgError, "duplicate");
341 }
342 servers_rev_map_[info] = server;
343 }
344 }
345}
346
347void
349 if (!params) {
350 isc_throw(BadValue, "gss_tsig parameters entry is mandatory");
351 }
352 if (params->getType() != Element::map) {
353 isc_throw(BadValue, "gss_tsig parameters entry must be a map");
354 }
355 try {
357 } catch(const DhcpConfigError& ex) {
358 isc_throw(BadValue, "gss_tsig " << ex.what() << " ("
359 << params->getPosition() << ")");
360 }
361
362 ConstElementPtr client_keytab = params->get("client-keytab");
363 if (client_keytab) {
364 setClientKeyTab(client_keytab->stringValue());
365 }
366
367 ConstElementPtr credentials_cache = params->get("credentials-cache");
368 if (credentials_cache) {
369 setCredsCache(credentials_cache->stringValue());
370 }
371
372 string retry_interval_origin = "default";
373 string retry_interval_location = "";
374 int64_t global_retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
375 ConstElementPtr global_retry_interval = params->get("retry-interval");
376 if (global_retry_interval) {
377 retry_interval_origin = "global";
378 retry_interval_location += " (";
379 retry_interval_location += global_retry_interval->getPosition().str();
380 retry_interval_location += ")";
381 global_retry_val = global_retry_interval->intValue();
382 if ((global_retry_val < 0) ||
383 (global_retry_val > numeric_limits<uint32_t>::max())) {
384 isc_throw(BadValue, "'retry-interval' parameter is out of "
385 "range [0.." << numeric_limits<uint32_t>::max()
386 << "]" << retry_interval_location);
387 }
388 }
389
390 string rekey_interval_origin = "default";
391 string rekey_interval_location = "";
392 int64_t global_rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
393 ConstElementPtr global_rekey_interval = params->get("rekey-interval");
394 if (global_rekey_interval) {
395 rekey_interval_origin = "global";
396 rekey_interval_location += " (";
397 rekey_interval_location += global_rekey_interval->getPosition().str();
398 rekey_interval_location += ")";
399 global_rekey_val = global_rekey_interval->intValue();
400 if ((global_rekey_val < 0) ||
401 (global_rekey_val > numeric_limits<uint32_t>::max())) {
402 isc_throw(BadValue, "'rekey-interval' parameter is out of "
403 "range [0.." << numeric_limits<uint32_t>::max()
404 << "]" << rekey_interval_location);
405 }
406 }
407
408 string tkey_lifetime_origin = "default";
409 string tkey_lifetime_location = "";
410 int64_t global_tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
411 ConstElementPtr global_tkey_lifetime = params->get("tkey-lifetime");
412 if (global_tkey_lifetime) {
413 tkey_lifetime_origin = "global";
414 tkey_lifetime_location += " (";
415 tkey_lifetime_location += global_tkey_lifetime->getPosition().str();
416 tkey_lifetime_location += ")";
417 global_tkey_lifetime_val = global_tkey_lifetime->intValue();
418 if ((global_tkey_lifetime_val < 0) ||
419 (global_tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
420 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
421 "range [0.." << numeric_limits<uint32_t>::max()
422 << "]" << tkey_lifetime_location);
423 }
424 }
425
426 if (global_retry_val >= global_rekey_val) {
427 isc_throw(BadValue, "the " << retry_interval_origin
428 << " 'retry-interval' parameter"
429 << retry_interval_location << " must be smaller then the "
430 << rekey_interval_origin << " 'rekey-interval' parameter"
431 << retry_interval_location << ": range [0.."
432 << global_rekey_val << "]");
433 }
434
435 if (global_rekey_val >= global_tkey_lifetime_val) {
436 isc_throw(BadValue, "the " << rekey_interval_origin
437 << " 'rekey-interval' parameter"
438 << rekey_interval_location << " must be smaller than the "
439 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
440 << tkey_lifetime_location << ": range [0.."
441 << global_tkey_lifetime_val << "]");
442 }
443
444 ConstElementPtr global_tkey_proto = params->get("tkey-protocol");
445 if (global_tkey_proto) {
446 string val = global_tkey_proto->stringValue();
447 if ((val != "UDP") && (val != "TCP")) {
448 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
449 "or TCP (" << global_tkey_proto->getPosition() << ")");
450 }
451 }
452
453 ConstElementPtr global_fallback = params->get("fallback");
454
455 ConstElementPtr global_tkey_timeout = params->get("exchange-timeout");
456 if (global_tkey_timeout) {
457 int64_t val = global_tkey_timeout->intValue();
458 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
459 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
460 "range [0.." << numeric_limits<uint32_t>::max()
461 << "] (" << global_tkey_timeout->getPosition() << ")");
462 }
463 }
464
465 ConstElementPtr servers = params->get("servers");
466 if (!servers) {
467 return;
468 }
469
470 uint32_t max_tkey_lifetime = 0;
471 for (auto const& map : servers->listValue()) {
472 if (!map) {
473 continue;
474 }
475 if (map->getType() != Element::map) {
476 isc_throw(BadValue, "'servers' parameter must be a list of "
477 "maps (" << map->getPosition() << ")");
478 }
479 try {
481 } catch (const DhcpConfigError& ex) {
482 isc_throw(BadValue, "gss_tsig server " << ex.what() << " ("
483 << map->getPosition() << ")");
484 }
485
486 ConstElementPtr id_elem = map->get("id");
487 if (!id_elem) {
488 isc_throw(BadValue, "'id' parameter is required in "
489 "gss_tsig server entry (" << map->getPosition() << ")");
490 }
491 const string& id = id_elem->stringValue();
492 if (id.empty()) {
493 isc_throw(BadValue, "'id' parameter must be not empty in "
494 "gss_tsig server entry (" << map->getPosition() << ")");
495 }
496 if (getServer(id)) {
497 isc_throw(BadValue, "'" << id << "' id is already used in "
498 "gss_tsig server entry (" << map->getPosition() << ")");
499 }
500
501 ConstElementPtr domains_list = map->get("domain-names");
502 set<string> domains;
503 if (domains_list && !domains_list->empty()) {
504 for (auto const& domain : domains_list->listValue()) {
505 if (!domain) {
506 continue;
507 }
508 if (domain->getType() != Element::string) {
509 isc_throw(BadValue, "gss_tsig server 'domain-names' list "
510 << "must contain only strings ("
511 << domain->getPosition() << ")");
512 }
513 // Ignore duplicates.
514 static_cast<void>(domains.insert(domain->stringValue()));
515 }
516 }
517
518 DnsServerPtr srv;
519 ConstElementPtr ip_address = map->get("ip-address");
520 if (!ip_address) {
521 isc_throw(BadValue, "'ip-address' parameter is required in "
522 "gss_tsig server entry (" << map->getPosition() << ")");
523 }
524 try {
525 IOAddress addr(ip_address->stringValue());
526 if (map->contains("port")) {
527 int64_t port(SimpleParser::getInteger(map, "port", 0,
528 numeric_limits<uint16_t>::max()));
529 srv.reset(new DnsServer(id, domains, addr,
530 static_cast<uint16_t>(port)));
531 } else {
532 srv.reset(new DnsServer(id, domains, addr));
533 }
534 } catch (const DhcpConfigError& ex) {
535 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what());
536 } catch (const std::exception& ex) {
537 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
538 << " (" << map->getPosition() << ")");
539 }
540
541 ConstElementPtr server_principal = map->get("server-principal");
542 bool server_principal_global = false;
543 if (!server_principal) {
544 server_principal = params->get("server-principal");
545 server_principal_global = true;
546 }
547 if (!server_principal) {
548 isc_throw(BadValue, "'server-principal' parameter is required in "
549 "gss_tsig server entry (" << map->getPosition() << ")");
550 }
551 srv->setServerPrincipal(server_principal->stringValue());
552 try {
553 srv->buildKeyNameSuffix();
554 } catch (const std::exception& ex) {
555 if (server_principal_global) {
556 isc_throw(BadValue, "gss_tsig bad server-principal parameter: "
557 << ex.what() << " ("
558 << server_principal->getPosition() << ")");
559 } else {
560 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
561 << " (" << server_principal->getPosition() << ")");
562 }
563 }
564
565 ConstElementPtr gss_replay_flag = map->get("gss-replay-flag");
566 if (!gss_replay_flag) {
567 gss_replay_flag = params->get("gss-replay-flag");
568 }
569 if (gss_replay_flag) {
570 srv->setGssReplayFlag(gss_replay_flag->boolValue());
571 }
572
573 ConstElementPtr gss_sequence_flag = map->get("gss-sequence-flag");
574 if (!gss_sequence_flag) {
575 gss_sequence_flag = params->get("gss-sequence-flag");
576 }
577 if (gss_sequence_flag) {
578 srv->setGssSequenceFlag(gss_sequence_flag->boolValue());
579 }
580
581 ConstElementPtr cred_principal = map->get("client-principal");
582 if (!cred_principal) {
583 cred_principal = params->get("client-principal");
584 }
585 if (cred_principal) {
586 srv->setClientPrincipal(cred_principal->stringValue());
587 }
588
589 retry_interval_location = "";
590 ConstElementPtr retry_interval = map->get("retry-interval");
591 if (!retry_interval) {
592 retry_interval = global_retry_interval;
593 } else {
594 retry_interval_origin = "server";
595 }
596 int64_t retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
597 if (retry_interval) {
598 retry_interval_location += " (";
599 retry_interval_location += retry_interval->getPosition().str();
600 retry_interval_location += ")";
601 retry_val = retry_interval->intValue();
602 if ((retry_val < 0) ||
603 (retry_val > numeric_limits<uint32_t>::max())) {
604 isc_throw(BadValue, "'retry-interval' parameter is out of "
605 "range [0.." << numeric_limits<uint32_t>::max()
606 << "]" << retry_interval_location);
607 }
608 srv->setRetryInterval(retry_val);
609 }
610
611 rekey_interval_location = "";
612 ConstElementPtr rekey_interval = map->get("rekey-interval");
613 if (!rekey_interval) {
614 rekey_interval = global_rekey_interval;
615 } else {
616 rekey_interval_origin = "server";
617 }
618 int64_t rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
619 if (rekey_interval) {
620 rekey_interval_location += " (";
621 rekey_interval_location += rekey_interval->getPosition().str();
622 rekey_interval_location += ")";
623 rekey_val = rekey_interval->intValue();
624 if ((rekey_val < 0) ||
625 (rekey_val > numeric_limits<uint32_t>::max())) {
626 isc_throw(BadValue, "'rekey-interval' parameter is out of "
627 "range [0.." << numeric_limits<uint32_t>::max()
628 << "]" << rekey_interval_location);
629 }
630 srv->setRekeyInterval(rekey_val);
631 }
632
633 tkey_lifetime_location = "";
634 ConstElementPtr tkey_lifetime = map->get("tkey-lifetime");
635 if (!tkey_lifetime) {
636 tkey_lifetime = global_tkey_lifetime;
637 } else {
638 tkey_lifetime_origin = "server";
639 }
640 int64_t tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
641 if (tkey_lifetime) {
642 tkey_lifetime_location += " (";
643 tkey_lifetime_location += tkey_lifetime->getPosition().str();
644 tkey_lifetime_location += ")";
645 tkey_lifetime_val = tkey_lifetime->intValue();
646 if ((tkey_lifetime_val < 0) ||
647 (tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
648 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
649 "range [0.." << numeric_limits<uint32_t>::max()
650 << "]" << tkey_lifetime_location);
651 }
652 srv->setKeyLifetime(tkey_lifetime_val);
653 }
654 if (tkey_lifetime_val > max_tkey_lifetime) {
655 max_tkey_lifetime = tkey_lifetime_val;
656 }
657
658 if (retry_val >= rekey_val) {
659 isc_throw(BadValue, "the " << retry_interval_origin
660 << " 'retry-interval' parameter"
661 << retry_interval_location << " must be smaller then the "
662 << rekey_interval_origin << " 'rekey-interval' parameter"
663 << retry_interval_location << ": range [0.."
664 << rekey_val << "]");
665 }
666
667 if (rekey_val >= tkey_lifetime_val) {
668 isc_throw(BadValue, "the " << rekey_interval_origin
669 << " 'rekey-interval' parameter"
670 << rekey_interval_location << " must be smaller than the "
671 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
672 << tkey_lifetime_location << ": range [0.."
673 << tkey_lifetime_val << "]");
674 }
675
676 ConstElementPtr tkey_proto = map->get("tkey-protocol");
677 if (!tkey_proto) {
678 tkey_proto = global_tkey_proto;
679 }
680 if (tkey_proto) {
681 string val = tkey_proto->stringValue();
682 if (val == "UDP") {
683 srv->setKeyProto(IOFetch::UDP);
684 } else if (val == "TCP") {
685 srv->setKeyProto(IOFetch::TCP);
686 } else {
687 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
688 "or TCP (" << tkey_proto->getPosition() << ")");
689 }
690 }
691
692 ConstElementPtr fallback = map->get("fallback");
693 if (!fallback) {
694 fallback = global_fallback;
695 }
696 if (fallback) {
697 srv->setFallback(fallback->boolValue());
698 }
699
700 ConstElementPtr tkey_timeout = params->get("exchange-timeout");
701 if (!tkey_timeout) {
702 tkey_timeout = global_tkey_timeout;
703 }
704 if (tkey_timeout) {
705 int64_t val = tkey_timeout->intValue();
706 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
707 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
708 "range [0.." << numeric_limits<uint32_t>::max()
709 << "] (" << tkey_timeout->getPosition() << ")");
710 }
711 srv->setExchangeTimeout(val);
712 }
713
714 addServer(srv);
715 }
716 setMaxKeyLifetime(max_tkey_lifetime);
717}
718
719} // end of namespace isc::gss_tsig
720} // 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:33
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.
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.
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:120
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.