nodeJS调用grpc域名证书验证及TSL/SSL配置的域名配置写法

调用文档示例

const root_cert = fs.readFileSync('path/to/root-cert');
const ssl_creds = grpc.credentials.createSsl(root_cert);
const stub = new helloworld.Greeter('myservice.example.com', ssl_creds);

但这个案例没说域名怎么配置。

我的:

const a= fs.readFileSync(path.join(__dirname,"/ca.crt"))//证书路径
const ssl_creds = grpc.credentials.createSsl(a);
const client = new helloworld.Greeter('xx.xx.xx.xx:xxxx', ssl_creds,{'grpc.ssl_target_name_override':'域名'});
client.sayHello(Request, (error, response) => {
      if (error) {
        console.log(error);
        return;
      }
      console.log(response);
    })
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值