Support export via TLS (fix #12).

This commit is contained in:
Nikita Vakula 2024-11-15 11:39:30 +01:00 committed by p-pautov
parent da2e4eb11b
commit 6c1659a20b
3 changed files with 55 additions and 8 deletions

View file

@ -17,10 +17,18 @@ public:
typedef std::function<void (Request, Response, grpc::Status)>
ResponseCb;
TraceServiceClient(const std::string& target)
TraceServiceClient(const std::string& target, bool ssl,
const std::string& trustedCert)
{
auto channel = grpc::CreateChannel(
target, grpc::InsecureChannelCredentials());
std::shared_ptr<grpc::ChannelCredentials> creds;
if (ssl) {
grpc::SslCredentialsOptions options;
options.pem_root_certs = trustedCert;
creds = grpc::SslCredentials(options);
} else {
creds = grpc::InsecureChannelCredentials();
}
auto channel = grpc::CreateChannel(target, creds);
channel->GetState(true); // trigger 'connecting' state
stub = TraceService::NewStub(channel);