gpt4 book ai didi

c++ - GRPC CreateChannel() 错误无法获取默认 pem 根证书

转载 作者:行者123 更新时间:2023-12-04 22:37:00 24 4
gpt4 key购买 nike

我在 Windows 10 上使用 grpc 1.35.0 并遵循示例代码 here创建一个 grpc channel 供客户端使用。但是我提供了一个根证书来创建 channel ,否则它会提示以下错误。
enter image description here
然后我用 python 版本编写我的客户端,我可以在不提供根证书的情况下创建 channel 。
那么,这是一个 grpc 错误还是我误解了示例代码?
GRPC 示例代码

// Create a default SSL ChannelCredentials object.
auto channel_creds = grpc::SslCredentials(grpc::SslCredentialsOptions());
// Create a channel using the credentials created in the previous step.
auto channel = grpc::CreateChannel(server_name, channel_creds);
// Create a stub on the channel.
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
// Make actual RPC calls on the stub.
grpc::Status s = stub->sayHello(&context, *request, response);
我的代码
const std::string SECURE_GRPC_CHANNEL_ADDRESS = <MY_SERVER>;

class GrpcChannel
{
GrpcChannel()
{
auto ca_cert = get_file_contents(cacert_path);
SslCredentialsOptions options = { ca_cert, "", "" };
auto channel_creds = SslCredentials(options);
channel_ = grpc::CreateChannel(SECURE_GRPC_CHANNEL_ADDRESS, channel_creds);
}

最佳答案

原来是 grpc 文档问题,用于 windows 的 grpc-core C++ 不支持默认根证书,需要用户指定一个。请引用here .

关于c++ - GRPC CreateChannel() 错误无法获取默认 pem 根证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67294977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com