Skip to content

Commit 06459d6

Browse files
committed
Add 'SslCaCrt' field to 'TGenericConnectorConfig'
1 parent 63de454 commit 06459d6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ydb/library/yql/providers/common/proto/gateways_config.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,11 @@ message TGenericConnectorConfig {
595595
// If true, GRPC Client will use TLS encryption.
596596
// Server cert will be verified with system CA cert pool.
597597
optional bool UseSsl = 4;
598+
// Path to the custom CA certificate that was used
599+
// during Connector key pair issuing.
600+
// If empty, the default system root certificates will be used
601+
// to verify Connector's cert.
602+
optional string SslCaCrt = 5;
598603

599604
reserved 1, 2;
600605
}

ydb/library/yql/providers/generic/connector/libcpp/client.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <util/stream/file.h>
2+
13
#include "client.h"
24

35
namespace NYql::NConnector {
@@ -21,10 +23,18 @@ namespace NYql::NConnector {
2123
public:
2224
TClientGRPC() = delete;
2325
TClientGRPC(const TGenericConnectorConfig& config) {
24-
TString endpoint = TStringBuilder() << config.GetEndpoint().host() << ":" << ToString(config.GetEndpoint().port());
25-
GrpcConfig_ = NYdbGrpc::TGRpcClientConfig(endpoint);
26+
GrpcConfig_ = NYdbGrpc::TGRpcClientConfig();
27+
GrpcConfig_.Locator = TStringBuilder() << config.GetEndpoint().host() << ":" << ToString(config.GetEndpoint().port());;
2628
GrpcConfig_.EnableSsl = config.GetUseSsl();
2729

30+
// Read content of CA cert
31+
TString rootCertData;
32+
if (config.GetSslCaCrt()) {
33+
rootCertData = TFileInput(config.GetSslCaCrt()).ReadAll();
34+
}
35+
36+
GrpcConfig_.SslCredentials = grpc::SslCredentialsOptions{.pem_root_certs = rootCertData, .pem_private_key = "", .pem_cert_chain = ""};
37+
2838
GrpcClient_ = std::make_unique<NYdbGrpc::TGRpcClientLow>();
2939

3040
// FIXME: is it OK to use single connection during the client lifetime?

0 commit comments

Comments
 (0)