You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "XiaoGang2015 (via GitHub)" <gi...@apache.org> on 2024/07/24 01:26:58 UTC

[I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

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-unsubscribe@brpc.apache.org.apache.org

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


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


Re: [I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on issue #2708:
URL: https://github.com/apache/brpc/issues/2708#issuecomment-2246968288

   如果不开启ssl,使用普通连接能连接成功吗?


-- 
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-unsubscribe@brpc.apache.org

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


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


Re: [I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

Posted by "XiaoGang2015 (via GitHub)" <gi...@apache.org>.
XiaoGang2015 commented on issue #2708:
URL: https://github.com/apache/brpc/issues/2708#issuecomment-2246975564

   > 如果不开启ssl,使用普通连接能连接成功吗?
   如果不开启ssl,普通连接是可以的
   


-- 
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-unsubscribe@brpc.apache.org

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


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


Re: [I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

Posted by "XiaoGang2015 (via GitHub)" <gi...@apache.org>.
XiaoGang2015 commented on issue #2708:
URL: https://github.com/apache/brpc/issues/2708#issuecomment-2249199789

   已经解决了,需要在客户端设置对应的SetSslTargetNameOverride


-- 
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-unsubscribe@brpc.apache.org

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


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


Re: [I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

Posted by "XiaoGang2015 (via GitHub)" <gi...@apache.org>.
XiaoGang2015 commented on issue #2708:
URL: https://github.com/apache/brpc/issues/2708#issuecomment-2246977677

   > 如果不开启ssl,使用普通连接能连接成功吗?
   
   通过抓包分析,能确认的是ssl 握手是成功的,客户端服务端交换了证书


-- 
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-unsubscribe@brpc.apache.org

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


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


Re: [I] grpc 客户端通过 ssl 连接 brpc 服务端 (brpc)

Posted by "XiaoGang2015 (via GitHub)" <gi...@apache.org>.
XiaoGang2015 closed issue #2708: grpc 客户端通过 ssl 连接 brpc 服务端
URL: https://github.com/apache/brpc/issues/2708


-- 
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-unsubscribe@brpc.apache.org

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


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