|
33 | 33 | #include <util/system/hostname.h> |
34 | 34 | #include <util/stream/file.h> |
35 | 35 | #include <util/system/file.h> |
| 36 | +#include <util/folder/path.h> |
36 | 37 | #include <util/generic/maybe.h> |
37 | 38 | #include <util/generic/map.h> |
38 | 39 | #include <util/generic/string.h> |
@@ -295,6 +296,7 @@ struct TCommonAppOptions { |
295 | 296 | ui32 MonitoringThreads = 10; |
296 | 297 | ui32 MonitoringMaxRequestsPerSecond = 0; |
297 | 298 | TString MonitoringCertificateFile; |
| 299 | + TString MonitoringPrivateKeyFile; |
298 | 300 | TString RestartsCountFile = ""; |
299 | 301 | size_t CompileInflightLimit = 100000; // MiniKQLCompileService |
300 | 302 | TString UDFsDir; |
@@ -385,7 +387,8 @@ struct TCommonAppOptions { |
385 | 387 | .RequiredArgument("NAME").StoreResult(&TenantName); |
386 | 388 | opts.AddLongOption("mon-port", "Monitoring port").OptionalArgument("NUM").StoreResult(&MonitoringPort); |
387 | 389 | opts.AddLongOption("mon-address", "Monitoring address").OptionalArgument("ADDR").StoreResult(&MonitoringAddress); |
388 | | - opts.AddLongOption("mon-cert", "Monitoring certificate (https)").OptionalArgument("PATH").StoreResult(&MonitoringCertificateFile); |
| 390 | + opts.AddLongOption("mon-cert", "Path to monitoring certificate file (https)").OptionalArgument("PATH").StoreResult(&MonitoringCertificateFile); |
| 391 | + opts.AddLongOption("mon-key", "Path to monitoring private key file (https)").OptionalArgument("PATH").StoreResult(&MonitoringPrivateKeyFile); |
389 | 392 | opts.AddLongOption("mon-threads", "Monitoring http server threads").RequiredArgument("NUM").StoreResult(&MonitoringThreads); |
390 | 393 | opts.AddLongOption("suppress-version-check", "Suppress version compatibility checking via IC").NoArgument().SetFlag(&SuppressVersionCheck); |
391 | 394 |
|
@@ -558,13 +561,12 @@ struct TCommonAppOptions { |
558 | 561 | ConfigUpdateTracer.AddUpdate(NKikimrConsole::TConfigItem::MonitoringConfigItem, TConfigItemInfo::EUpdateKind::UpdateExplicitly); |
559 | 562 | } |
560 | 563 | if (MonitoringCertificateFile) { |
561 | | - TString sslCertificate = TUnbufferedFileInput(MonitoringCertificateFile).ReadAll(); |
562 | | - if (!sslCertificate.empty()) { |
563 | | - appConfig.MutableMonitoringConfig()->SetMonitoringCertificate(sslCertificate); |
564 | | - ConfigUpdateTracer.AddUpdate(NKikimrConsole::TConfigItem::MonitoringConfigItem, TConfigItemInfo::EUpdateKind::UpdateExplicitly); |
565 | | - } else { |
566 | | - ythrow yexception() << "invalid ssl certificate file"; |
567 | | - } |
| 564 | + appConfig.MutableMonitoringConfig()->SetMonitoringCertificateFile(MonitoringCertificateFile); |
| 565 | + ConfigUpdateTracer.AddUpdate(NKikimrConsole::TConfigItem::MonitoringConfigItem, TConfigItemInfo::EUpdateKind::UpdateExplicitly); |
| 566 | + } |
| 567 | + if (MonitoringPrivateKeyFile) { |
| 568 | + appConfig.MutableMonitoringConfig()->SetMonitoringPrivateKeyFile(MonitoringPrivateKeyFile); |
| 569 | + ConfigUpdateTracer.AddUpdate(NKikimrConsole::TConfigItem::MonitoringConfigItem, TConfigItemInfo::EUpdateKind::UpdateExplicitly); |
568 | 570 | } |
569 | 571 | if (SqsHttpPort) { |
570 | 572 | appConfig.MutableSqsConfig()->MutableHttpServerConfig()->SetPort(SqsHttpPort); |
@@ -1148,6 +1150,7 @@ class TInitialConfiguratorImpl |
1148 | 1150 | Option(nullptr, TCfg::TTracingConfigFieldTag{}); |
1149 | 1151 | Option(nullptr, TCfg::TFailureInjectionConfigFieldTag{}); |
1150 | 1152 |
|
| 1153 | + ValidateCertPaths(); |
1151 | 1154 | CommonAppOptions.ApplyFields(AppConfig, Env, ConfigUpdateTracer); |
1152 | 1155 |
|
1153 | 1156 | // MessageBus options. |
@@ -1411,6 +1414,28 @@ class TInitialConfiguratorImpl |
1411 | 1414 | debugInfo.OldDynConfig.CopyFrom(InitDebug.OldConfig); |
1412 | 1415 | debugInfo.NewDynConfig.CopyFrom(InitDebug.YamlConfig); |
1413 | 1416 | } |
| 1417 | + |
| 1418 | + void ValidateCertPaths() const { |
| 1419 | + auto ensureFileExists = [](const TString& path, TStringBuf optName) { |
| 1420 | + if (path.empty()) { |
| 1421 | + return; |
| 1422 | + } |
| 1423 | + TFsPath fspath(path); |
| 1424 | + TFileStat filestat; |
| 1425 | + if (!fspath.Stat(filestat) || !filestat.IsFile()) { |
| 1426 | + ythrow yexception() << "File passed to --" << optName << " does not exist: " << path; |
| 1427 | + } |
| 1428 | + }; |
| 1429 | + |
| 1430 | + ensureFileExists(CommonAppOptions.PathToInterconnectCertFile, "cert/ic-cert"); |
| 1431 | + ensureFileExists(CommonAppOptions.PathToInterconnectPrivateKeyFile, "key/ic-key"); |
| 1432 | + ensureFileExists(CommonAppOptions.PathToInterconnectCaFile, "ca/ic-ca"); |
| 1433 | + ensureFileExists(CommonAppOptions.GrpcSslSettings.PathToGrpcCertFile, "grpc-cert"); |
| 1434 | + ensureFileExists(CommonAppOptions.GrpcSslSettings.PathToGrpcPrivateKeyFile, "grpc-key"); |
| 1435 | + ensureFileExists(CommonAppOptions.GrpcSslSettings.PathToGrpcCaFile, "grpc-ca"); |
| 1436 | + ensureFileExists(CommonAppOptions.MonitoringCertificateFile, "mon-cert"); |
| 1437 | + ensureFileExists(CommonAppOptions.MonitoringPrivateKeyFile, "mon-key"); |
| 1438 | + } |
1414 | 1439 | }; |
1415 | 1440 |
|
1416 | 1441 | std::unique_ptr<IInitialConfigurator> MakeDefaultInitialConfigurator( |
|
0 commit comments