nodejs - 证书链中的错误自签名证书 [英] nodejs - error self signed certificate in certificate chain

查看:1343
本文介绍了nodejs - 证书链中的错误自签名证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到客户端https请求的问题。

I am facing a problem with client side https requests.

一个片段如下所示:

var fs = require('fs');
var https = require('https');

var options = {
    hostname: 'someHostName.com',
    port: 443,
    path: '/path',
    method: 'GET',
    key: fs.readFileSync('key.key'),
    cert: fs.readFileSync('certificate.crt')
}

var requestGet = https.request(options, function(res){
    console.log('resObj', res);
}

我得到的是错误:证书链中的自签名证书。

What I get is Error: self signed certificate in certificate chain.

当我使用Postman时,我可以导入客户端证书和密钥并使用它没有任何问题。有没有任何解决方案?我也想了解邮递员如何处理证书和工作。

When I use Postman I can import the client certificate and key and use it without any problem. Is there any solution available?? I would also like to be given some lights on how postman handles the certificates and works.

推荐答案

您需要添加 NODE_TLS_REJECT_UNAUTHORIZED ='0'作为环境变量。

You need to add NODE_TLS_REJECT_UNAUTHORIZED='0' as an environment variable.

这篇关于nodejs - 证书链中的错误自签名证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆