MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / connectToKeeper

Method connectToKeeper

programs/keeper-client/KeeperClient.cpp:615–713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615void KeeperClient::connectToKeeper()
616{
617#if USE_SSL
618 /// Configure SSL context if TLS options are provided
619 if (config().has("tls-cert-file") || config().has("tls-key-file") || config().has("tls-ca-file") || config().has("accept-invalid-certificate"))
620 {
621 Poco::Net::Context::VerificationMode verification_mode = Poco::Net::Context::VERIFY_RELAXED;
622
623 if (config().has("accept-invalid-certificate"))
624 {
625 verification_mode = Poco::Net::Context::VERIFY_NONE;
626 }
627
628 auto context = Poco::Net::Context::Ptr(new Poco::Net::Context(
629 Poco::Net::Context::TLSV1_2_CLIENT_USE,
630 config().getString("tls-key-file", ""),
631 config().getString("tls-cert-file", ""),
632 config().getString("tls-ca-file", ""),
633 verification_mode,
634 9,
635 true,
636 "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"
637 ));
638
639 Poco::Net::SSLManager::InvalidCertificateHandlerPtr certificate_handler;
640 if (config().has("accept-invalid-certificate"))
641 {
642 certificate_handler = new Poco::Net::AcceptCertificateHandler(false);
643 }
644 else
645 {
646 certificate_handler = new Poco::Net::RejectCertificateHandler(false);
647 }
648
649 Poco::Net::SSLManager::instance().initializeClient(nullptr, certificate_handler, context);
650 }
651#endif
652
653 ConfigProcessor config_processor(config().getString("config-file", "config.xml"));
654
655 /// This will handle a situation when clickhouse is running on the embedded config, but config.d folder is also present.
656 ConfigProcessor::registerEmbeddedConfig("config.xml", "<clickhouse/>");
657 auto clickhouse_config = config_processor.loadConfig();
658
659 Poco::Util::AbstractConfiguration::Keys keys;
660 clickhouse_config.configuration->keys("zookeeper", keys);
661
662 zkutil::ZooKeeperArgs new_zk_args;
663
664 if (!config().has("host") && !config().has("port") && !keys.empty())
665 {
666 LOG_INFO(getLogger("KeeperClient"), "Found keeper node in the config.xml, will use it for connection");
667
668 for (const auto & key : keys)
669 {
670 if (key != "node")
671 continue;
672

Callers

nothing calls this directly

Calls 14

PtrClass · 0.85
setCurrentComponentFunction · 0.85
initializeClientMethod · 0.80
keysMethod · 0.80
getLoggerFunction · 0.50
hasMethod · 0.45
getStringMethod · 0.45
loadConfigMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected