How to connect to a gRPC Server hosted in Kestrel as HTTPS from a gRPC C++ Client using default certificates (Windows 10)?

Viewed 805

I am using ASP.Net Core (Grpc.Net) for creating a HTTPS gRPC server hosted in Kestrel. The communication between C# Client to the server (HTTPS) works fine with out adding any certificate.

It looks like they are using the default certificates for communication.

Now I have a C++ gRPC Client in Windows 10 and I'm trying to connect to the same server from a client, the endpoint is https://localhost:50051.

This is my Kestrel configuration @server.

webBuilder.ConfigureKestrel(serverOptions =>
                {
                    serverOptions.Listen(IPAddress.Any, 50051, listenOptions =>
                   {
                       listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
                       listenOptions.UseHttps();

                   });
                }).UseStartup<Startup>();

As you could see I am not using certificates in the server (wanted to use default certificates) the same way I used C# gRPC Client.

i.e. connection to server works using C# Client

var channel = GrpcChannel.ForAddress("https://localhost:50051");
ecgDataClient = new Data.DataClient(channel);

But with C++ gRPC Client Client I am unable to connect (tried both InSecure & SslCredentials):

auto channel_creds = grpc::SslCredentials(grpc::SslCredentialsOptions());
DataGrpcClient grpcClient( grpc::CreateChannel("localhost:50051", channel_creds));

With grpc::SslCredentials(grpc::SslCredentialsOptions()) I get this error:

E0709 19:46:20.488000000 6724 ssl_utils.cc:570] load_file: {"created":"@1625840180.488000000","description":"Failed to load file","file":"D:\DEV\vcpkg\buildtrees\grpc\src\17cc203898-db2679e7f2.clean\src\core\lib\iomgr\load_file.cc","file_line":72,"filename":"/usr/share/grpc/roots.pem","referenced_errors":[{"created":"@1625840180.488000000","description":"No such file or directory","errno":2,"file":"D:\DEV\vcpkg\buildtrees\grpc\src\17cc203898-db2679e7f2.clean\src\core\lib\iomgr\load_file.cc","file_line":45,"os_error":"No such file or directory","syscall":"fopen"}]}
E0709 19:46:20.509000000 6724 ssl_security_connector.cc:413] Could not get default pem root certs.
E0709 19:46:20.512000000 6724 secure_channel_create.cc:108] Failed to create secure subchannel for secure name 'localhost:50051'
E0709 19:46:20.517000000 6724 secure_channel_create.cc:50] Failed to create channel args during subchannel creation.
E0709 19:46:20.521000000 6724 ssl_security_connector.cc:413] Could not get default pem root certs.
E0709 19:46:20.525000000 6724 secure_channel_create.cc:108] Failed to create secure subchannel for secure name 'localhost:50051'
E0709 19:46:20.529000000 6724 secure_channel_create.cc:50] Failed to create channel args during subchannel creation.

It looks like unable to find the default certificates. I am running my C++ gRPC Client in Windows 10, should I need to do anything so that the client picks the default certificates?

Thanks Basanth

0 Answers
Related