XiaoGang2015 opened a new issue, #2708:
URL: https://github.com/apache/brpc/issues/2708

   **问题描述**
   如何使用 grpc 客户端通过 ssl 连接 brpc 服务端?
   我尝试的方法:
   客户端相关代码:
   ```c++
       grpc_impl::ChannelArguments ag;
       ag.SetMaxReceiveMessageSize(DATA_BUF_SIZE);
       ag.SetMaxSendMessageSize(DATA_BUF_SIZE);
       grpc::SslCredentialsOptions sslOptions;
       sslOptions.pem_root_certs = rC; // 对应的 文件
       sslOptions.pem_private_key = pc;  // 对应的文件
       sslOptions.pem_cert_chain = cc; // 对应的文件
   
       auto cha = grpc::CreateCustomChannel(ipAddr, 
grpc::SslCredentials(sslOptions), ag);
       std::unique_ptr<bimmsg::BimService::Stub> 
stub_(bimmsg::BimService::NewStub(cha));
   
       // send msg
       grpc::ClientContext context;
       bimmsg::ProjStandardDataResp reply;
       grpc::Status status = stub_->ProjStandardDataRpc(&context, req, &reply);
   ```
   服务端相关代码:
   ```c++
       options.mutable_ssl_options()->default_cert.certificate = 
"/home/xiaogang/CA/server.crt";
       options.mutable_ssl_options()->default_cert.private_key = 
"/home/xiaogang/CA/server.key";
       options.mutable_ssl_options()->strict_sni = false;
       options.mutable_ssl_options()->verify.ca_file_path = 
"/home/xiaogang/CA/ca.crt";
       options.mutable_ssl_options()->verify.verify_depth = 1;
       options.mutable_ssl_options()->alpns = "h2";
       options.mutable_ssl_options()->disable_ssl3 = true;
   ```
   **返回错误**
   grpc 返回的错误码 unavailable(14), failed to connect all address.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to