Skip to content

Commit 3f77e0f

Browse files
udf: enable TLS when secure=true using SslCredentials (#245)
1 parent 9eef31b commit 3f77e0f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/jogasaki/udf/udf_loader.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,19 @@ load_result udf_loader::create_api_from_handle(
231231
full_path,
232232
"Symbol 'tsurugi_create_generic_client_factory' not found"};
233233
}
234+
std::shared_ptr<grpc::ChannelCredentials> creds;
234235
if (cfg->secure()) {
235-
return {load_status::ini_invalid, full_path, "Currently, only 'false' secure are supported"};
236+
grpc::SslCredentialsOptions opts;
237+
creds = grpc::SslCredentials(opts);
238+
VLOG(jogasaki::log_trace) << jogasaki::udf::log::prefix
239+
<< "Creating TLS channel to endpoint: " << cfg->endpoint()
240+
<< " (using system root certificates)";
241+
} else {
242+
creds = grpc::InsecureChannelCredentials();
243+
VLOG(jogasaki::log_trace) << jogasaki::udf::log::prefix
244+
<< "Creating INSECURE channel to endpoint: " << cfg->endpoint();
236245
}
237-
auto channel = grpc::CreateChannel(cfg->endpoint(), grpc::InsecureChannelCredentials());
246+
auto channel = grpc::CreateChannel(cfg->endpoint(), creds);
238247
auto raw_client = factory_ptr->create(channel);
239248
if(! raw_client) {
240249
return {load_status::factory_creation_failed, full_path, "Failed to create generic client from factory"};

0 commit comments

Comments
 (0)