我正在开发一个登录我本地无线路由器(Linksys)的小应用程序,但我遇到了路由器的自签名证书问题.
我运行wget 192.168.1.1并得到:
ERROR: cannot verify 192.168.1.1's certificate, issued by `/C=US/ST=California/L=Irvine/O=Cisco-Linksys, LLC/OU=Division/CN=Linksys/emailAddress=support@linksys.com':
Self-signed certificate encountered.
ERROR: certificate common name `Linksys' doesn't match requested host name `192.168.1.1'.
To connect to 192.168.1.1 insecurely, use `--no-check-certificate'.
Run Code Online (Sandbox Code Playgroud)
在节点中,捕获的错误是:
{ [Error: socket hang up] code: 'ECONNRESET' }
Run Code Online (Sandbox Code Playgroud)
我目前的示例代码是:
var req = https.request({
host: '192.168.1.1',
port: 443,
path: '/',
method: 'GET'
}, function(res){
var body = [];
res.on('data', function(data){
body.push(data);
});
res.on('end', function(){
console.log( body.join('') );
});
});
req.end();
req.on('error', function(err){
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能让node.js做相当于"--no-check-certificate"的操作?
我正在向具有自签名证书的服务器发出https请求(使用请求模块).如果我没有指定strictSSL: false选项,则会抛出错误.
此证书已在我的操作系统(OSX)上受到信任,因此Chrome在从该服务器访问网页时不会出错.
我了解不同的应用程序/环境可能有自己的证书库.Firefox有自己的,例如,JVM通常位于$ JAVA_HOME/jre/lib/security/cacerts(在OSX上).
我的问题是,节点在哪里寻找其可信任的CA?有这样的概念吗?我想在那里添加我自签名的证书以用于开发目的.