Kea 3.1.5
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 { "exchange-timeout", Element::integer },
300 { "servers", Element::list },
301 { "user-context", Element::map },
302 { "comment", Element::string }
303};
304
306 : servers_(), servers_rev_map_(), client_keytab_(""), creds_cache_(""),
307 max_tkey_lifetime_(0) {
308}
309
312
315 auto candidate = servers_rev_map_.find(server_info);
316 if (candidate == servers_rev_map_.end()) {
317 return (DnsServerPtr());
318 }
319 return (candidate->second);
320}
321
323GssTsigCfg::getServer(const string& id) const {
324 auto const& index = servers_.template get<DnsServerIdTag>();
325 auto const it = index.find(id);
326 if (it == index.cend()) {
327 return (DnsServerPtr());
328 }
329 return (*it);
330}
331
332void
334 if (!servers_rev_map_.empty()) {
335 isc_throw(D2CfgError, "server reverse map is not empty");
336 }
337 for (auto const& server : getServerList()) {
338 server->buildServerInfo(d2_config);
339 for (auto const& info : server->getServerInfos()) {
340 if (servers_rev_map_.count(info) > 0) {
341 isc_throw(D2CfgError, "duplicate");
342 }
343 servers_rev_map_[info] = server;
344 }
345 }
346}
347
348void
350 if (!params) {
351 isc_throw(BadValue, "gss_tsig parameters entry is mandatory");
352 }
353 if (params->getType() != Element::map) {
354 isc_throw(BadValue, "gss_tsig parameters entry must be a map");
355 }
356 try {
358 } catch(const DhcpConfigError& ex) {
359 isc_throw(BadValue, "gss_tsig " << ex.what() << " ("
360 << params->getPosition() << ")");
361 }
362
363 ConstElementPtr client_keytab = params->get("client-keytab");
364 if (client_keytab) {
365 setClientKeyTab(client_keytab->stringValue());
366 }
367
368 ConstElementPtr credentials_cache = params->get("credentials-cache");
369 if (credentials_cache) {
370 setCredsCache(credentials_cache->stringValue());
371 }
372
373 string retry_interval_origin = "default";
374 string retry_interval_location = "";
375 int64_t global_retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
376 ConstElementPtr global_retry_interval = params->get("retry-interval");
377 if (global_retry_interval) {
378 retry_interval_origin = "global";
379 retry_interval_location += " (";
380 retry_interval_location += global_retry_interval->getPosition().str();
381 retry_interval_location += ")";
382 global_retry_val = global_retry_interval->intValue();
383 if ((global_retry_val < 0) ||
384 (global_retry_val > numeric_limits<uint32_t>::max())) {
385 isc_throw(BadValue, "'retry-interval' parameter is out of "
386 "range [0.." << numeric_limits<uint32_t>::max()
387 << "]" << retry_interval_location);
388 }
389 }
390
391 string rekey_interval_origin = "default";
392 string rekey_interval_location = "";
393 int64_t global_rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
394 ConstElementPtr global_rekey_interval = params->get("rekey-interval");
395 if (global_rekey_interval) {
396 rekey_interval_origin = "global";
397 rekey_interval_location += " (";
398 rekey_interval_location += global_rekey_interval->getPosition().str();
399 rekey_interval_location += ")";
400 global_rekey_val = global_rekey_interval->intValue();
401 if ((global_rekey_val < 0) ||
402 (global_rekey_val > numeric_limits<uint32_t>::max())) {
403 isc_throw(BadValue, "'rekey-interval' parameter is out of "
404 "range [0.." << numeric_limits<uint32_t>::max()
405 << "]" << rekey_interval_location);
406 }
407 }
408
409 string tkey_lifetime_origin = "default";
410 string tkey_lifetime_location = "";
411 int64_t global_tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
412 ConstElementPtr global_tkey_lifetime = params->get("tkey-lifetime");
413 if (global_tkey_lifetime) {
414 tkey_lifetime_origin = "global";
415 tkey_lifetime_location += " (";
416 tkey_lifetime_location += global_tkey_lifetime->getPosition().str();
417 tkey_lifetime_location += ")";
418 global_tkey_lifetime_val = global_tkey_lifetime->intValue();
419 if ((global_tkey_lifetime_val < 0) ||
420 (global_tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
421 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
422 "range [0.." << numeric_limits<uint32_t>::max()
423 << "]" << tkey_lifetime_location);
424 }
425 }
426
427 if (global_retry_val >= global_rekey_val) {
428 isc_throw(BadValue, "the " << retry_interval_origin
429 << " 'retry-interval' parameter"
430 << retry_interval_location << " must be smaller then the "
431 << rekey_interval_origin << " 'rekey-interval' parameter"
432 << retry_interval_location << ": range [0.."
433 << global_rekey_val << "]");
434 }
435
436 if (global_rekey_val >= global_tkey_lifetime_val) {
437 isc_throw(BadValue, "the " << rekey_interval_origin
438 << " 'rekey-interval' parameter"
439 << rekey_interval_location << " must be smaller than the "
440 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
441 << tkey_lifetime_location << ": range [0.."
442 << global_tkey_lifetime_val << "]");
443 }
444
445 ConstElementPtr global_tkey_proto = params->get("tkey-protocol");
446 if (global_tkey_proto) {
447 string val = global_tkey_proto->stringValue();
448 if ((val != "UDP") && (val != "TCP")) {
449 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
450 "or TCP (" << global_tkey_proto->getPosition() << ")");
451 }
452 }
453
454 ConstElementPtr global_fallback = params->get("fallback");
455
456 ConstElementPtr global_tkey_timeout = params->get("exchange-timeout");
457 if (global_tkey_timeout) {
458 int64_t val = global_tkey_timeout->intValue();
459 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
460 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
461 "range [0.." << numeric_limits<uint32_t>::max()
462 << "] (" << global_tkey_timeout->getPosition() << ")");
463 }
464 }
465
466 ConstElementPtr servers = params->get("servers");
467 if (!servers) {
468 return;
469 }
470
471 uint32_t max_tkey_lifetime = 0;
472 for (auto const& map : servers->listValue()) {
473 if (!map) {
474 continue;
475 }
476 if (map->getType() != Element::map) {
477 isc_throw(BadValue, "'servers' parameter must be a list of "
478 "maps (" << map->getPosition() << ")");
479 }
480 try {
482 } catch (const DhcpConfigError& ex) {
483 isc_throw(BadValue, "gss_tsig server " << ex.what() << " ("
484 << map->getPosition() << ")");
485 }
486
487 ConstElementPtr id_elem = map->get("id");
488 if (!id_elem) {
489 isc_throw(BadValue, "'id' parameter is required in "
490 "gss_tsig server entry (" << map->getPosition() << ")");
491 }
492 const string& id = id_elem->stringValue();
493 if (id.empty()) {
494 isc_throw(BadValue, "'id' parameter must be not empty in "
495 "gss_tsig server entry (" << map->getPosition() << ")");
496 }
497 if (getServer(id)) {
498 isc_throw(BadValue, "'" << id << "' id is already used in "
499 "gss_tsig server entry (" << map->getPosition() << ")");
500 }
501
502 ConstElementPtr domains_list = map->get("domain-names");
503 set<string> domains;
504 if (domains_list && !domains_list->empty()) {
505 for (auto const& domain : domains_list->listValue()) {
506 if (!domain) {
507 continue;
508 }
509 if (domain->getType() != Element::string) {
510 isc_throw(BadValue, "gss_tsig server 'domain-names' list "
511 << "must contain only strings ("
512 << domain->getPosition() << ")");
513 }
514 // Ignore duplicates.
515 static_cast<void>(domains.insert(domain->stringValue()));
516 }
517 }
518
519 DnsServerPtr srv;
520 ConstElementPtr ip_address = map->get("ip-address");
521 if (!ip_address) {
522 isc_throw(BadValue, "'ip-address' parameter is required in "
523 "gss_tsig server entry (" << map->getPosition() << ")");
524 }
525 try {
526 IOAddress addr(ip_address->stringValue());
527 if (map->contains("port")) {
528 int64_t port(SimpleParser::getInteger(map, "port", 0,
529 numeric_limits<uint16_t>::max()));
530 srv.reset(new DnsServer(id, domains, addr,
531 static_cast<uint16_t>(port)));
532 } else {
533 srv.reset(new DnsServer(id, domains, addr));
534 }
535 } catch (const DhcpConfigError& ex) {
536 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what());
537 } catch (const std::exception& ex) {
538 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
539 << " (" << map->getPosition() << ")");
540 }
541
542 ConstElementPtr server_principal = map->get("server-principal");
543 bool server_principal_global = false;
544 if (!server_principal) {
545 server_principal = params->get("server-principal");
546 server_principal_global = true;
547 }
548 if (!server_principal) {
549 isc_throw(BadValue, "'server-principal' parameter is required in "
550 "gss_tsig server entry (" << map->getPosition() << ")");
551 }
552 srv->setServerPrincipal(server_principal->stringValue());
553 try {
554 srv->buildKeyNameSuffix();
555 } catch (const std::exception& ex) {
556 if (server_principal_global) {
557 isc_throw(BadValue, "gss_tsig bad server-principal parameter: "
558 << ex.what() << " ("
559 << server_principal->getPosition() << ")");
560 } else {
561 isc_throw(BadValue, "gss_tsig bad server entry: " << ex.what()
562 << " (" << server_principal->getPosition() << ")");
563 }
564 }
565
566 ConstElementPtr gss_replay_flag = map->get("gss-replay-flag");
567 if (!gss_replay_flag) {
568 gss_replay_flag = params->get("gss-replay-flag");
569 }
570 if (gss_replay_flag) {
571 srv->setGssReplayFlag(gss_replay_flag->boolValue());
572 }
573
574 ConstElementPtr gss_sequence_flag = map->get("gss-sequence-flag");
575 if (!gss_sequence_flag) {
576 gss_sequence_flag = params->get("gss-sequence-flag");
577 }
578 if (gss_sequence_flag) {
579 srv->setGssSequenceFlag(gss_sequence_flag->boolValue());
580 }
581
582 ConstElementPtr cred_principal = map->get("client-principal");
583 if (!cred_principal) {
584 cred_principal = params->get("client-principal");
585 }
586 if (cred_principal) {
587 srv->setClientPrincipal(cred_principal->stringValue());
588 }
589
590 retry_interval_location = "";
591 ConstElementPtr retry_interval = map->get("retry-interval");
592 if (!retry_interval) {
593 retry_interval = global_retry_interval;
594 } else {
595 retry_interval_origin = "server";
596 }
597 int64_t retry_val = DnsServer::DEFAULT_RETRY_INTERVAL;
598 if (retry_interval) {
599 retry_interval_location += " (";
600 retry_interval_location += retry_interval->getPosition().str();
601 retry_interval_location += ")";
602 retry_val = retry_interval->intValue();
603 if ((retry_val < 0) ||
604 (retry_val > numeric_limits<uint32_t>::max())) {
605 isc_throw(BadValue, "'retry-interval' parameter is out of "
606 "range [0.." << numeric_limits<uint32_t>::max()
607 << "]" << retry_interval_location);
608 }
609 srv->setRetryInterval(retry_val);
610 }
611
612 rekey_interval_location = "";
613 ConstElementPtr rekey_interval = map->get("rekey-interval");
614 if (!rekey_interval) {
615 rekey_interval = global_rekey_interval;
616 } else {
617 rekey_interval_origin = "server";
618 }
619 int64_t rekey_val = DnsServer::DEFAULT_REKEY_INTERVAL;
620 if (rekey_interval) {
621 rekey_interval_location += " (";
622 rekey_interval_location += rekey_interval->getPosition().str();
623 rekey_interval_location += ")";
624 rekey_val = rekey_interval->intValue();
625 if ((rekey_val < 0) ||
626 (rekey_val > numeric_limits<uint32_t>::max())) {
627 isc_throw(BadValue, "'rekey-interval' parameter is out of "
628 "range [0.." << numeric_limits<uint32_t>::max()
629 << "]" << rekey_interval_location);
630 }
631 srv->setRekeyInterval(rekey_val);
632 }
633
634 tkey_lifetime_location = "";
635 ConstElementPtr tkey_lifetime = map->get("tkey-lifetime");
636 if (!tkey_lifetime) {
637 tkey_lifetime = global_tkey_lifetime;
638 } else {
639 tkey_lifetime_origin = "server";
640 }
641 int64_t tkey_lifetime_val = DnsServer::DEFAULT_KEY_LIFETIME;
642 if (tkey_lifetime) {
643 tkey_lifetime_location += " (";
644 tkey_lifetime_location += tkey_lifetime->getPosition().str();
645 tkey_lifetime_location += ")";
646 tkey_lifetime_val = tkey_lifetime->intValue();
647 if ((tkey_lifetime_val < 0) ||
648 (tkey_lifetime_val > numeric_limits<uint32_t>::max())) {
649 isc_throw(BadValue, "'tkey-lifetime' parameter is out of "
650 "range [0.." << numeric_limits<uint32_t>::max()
651 << "]" << tkey_lifetime_location);
652 }
653 srv->setKeyLifetime(tkey_lifetime_val);
654 }
655 if (tkey_lifetime_val > max_tkey_lifetime) {
656 max_tkey_lifetime = tkey_lifetime_val;
657 }
658
659 if (retry_val >= rekey_val) {
660 isc_throw(BadValue, "the " << retry_interval_origin
661 << " 'retry-interval' parameter"
662 << retry_interval_location << " must be smaller then the "
663 << rekey_interval_origin << " 'rekey-interval' parameter"
664 << retry_interval_location << ": range [0.."
665 << rekey_val << "]");
666 }
667
668 if (rekey_val >= tkey_lifetime_val) {
669 isc_throw(BadValue, "the " << rekey_interval_origin
670 << " 'rekey-interval' parameter"
671 << rekey_interval_location << " must be smaller than the "
672 << tkey_lifetime_origin << " 'tkey-lifetime' parameter"
673 << tkey_lifetime_location << ": range [0.."
674 << tkey_lifetime_val << "]");
675 }
676
677 ConstElementPtr tkey_proto = map->get("tkey-protocol");
678 if (!tkey_proto) {
679 tkey_proto = global_tkey_proto;
680 }
681 if (tkey_proto) {
682 string val = tkey_proto->stringValue();
683 if (val == "UDP") {
684 srv->setKeyProto(IOFetch::UDP);
685 } else if (val == "TCP") {
686 srv->setKeyProto(IOFetch::TCP);
687 } else {
688 isc_throw(BadValue, "'tkey-protocol' parameter must be UDP "
689 "or TCP (" << tkey_proto->getPosition() << ")");
690 }
691 }
692
693 ConstElementPtr fallback = map->get("fallback");
694 if (!fallback) {
695 fallback = global_fallback;
696 }
697 if (fallback) {
698 srv->setFallback(fallback->boolValue());
699 }
700
701 ConstElementPtr tkey_timeout = map->get("exchange-timeout");
702 if (!tkey_timeout) {
703 tkey_timeout = global_tkey_timeout;
704 }
705 if (tkey_timeout) {
706 int64_t val = tkey_timeout->intValue();
707 if ((val < 0) || (val > numeric_limits<uint32_t>::max())) {
708 isc_throw(BadValue, "'exchange-timeout' parameter is out of "
709 "range [0.." << numeric_limits<uint32_t>::max()
710 << "] (" << tkey_timeout->getPosition() << ")");
711 }
712 srv->setExchangeTimeout(val);
713 }
714
715 addServer(srv);
716 }
717 setMaxKeyLifetime(max_tkey_lifetime);
718}
719
720} // end of namespace isc::gss_tsig
721} // 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.
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.