简体   繁体   English

Nodejs Fetch API:无法验证第一个证书

[英]Nodejs Fetch API: unable to verify the first certificate

I'm using the fetch API module in my Philips Hue project and when I make a call to the local ip address (my hub) it produces that error in the title.我在我的 Philips Hue 项目中使用 fetch API 模块,当我调用本地 ip 地址(我的集线器)时,它会在标题中产生该错误。

const fetch = require('node-fetch');
const gateway = "192.168.0.12";
const username = "username";

let getLights = function(){
    fetch(`https://${gateway}/api/${username}/lights`, {
        method: 'GET'
    }).then((res) => {
        return res.json();
    }).then((json) => {
        console.log(json);
    });
}


module.exports = {getLights};

Any SECURE fix this will eventually go onto the public internet for me to access my lights from anywhere sooo?任何安全修复最终都会将 go 放到公共互联网上,让我可以从任何地方访问我的灯吗?

It seems like you tried to access it using HTTPS.您似乎尝试使用 HTTPS 访问它。 Most likely on your local network it is going to be HTTP最有可能在您的本地网络上它将是 HTTP

So by changing https://${gateway}/api/${username}/lights to http://${gateway}/api/${username}/lights should work.因此,通过将https://${gateway}/api/${username}/lights更改为http://${gateway}/api/${username}/lights应该可以工作。

If you're trying to keep it HTTPS then you will have to install a SSL certificate authority onto your network.如果您想保留它 HTTPS 那么您将必须在您的网络上安装 SSL 证书颁发机构。
These may be useful sources if you're trying to get that done:如果你想完成这些,这些可能是有用的资源:

https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/ https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/

https://letsencrypt.org/docs/certificates-for-localhost/ https://letsencrypt.org/docs/certificates-for-localhost/

To skip the SSL tests, you can use this:要跳过 SSL 测试,您可以使用以下命令:

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用loopbackjs验证nodejs中的第一个证书 - unable to verify the first certificate in nodejs with loopbackjs 无法验证第一个证书 - Nodejs TLS - Unable to verify the first certificate - Nodejs TLS 错误:无法验证nodejs中的第一个证书 - Error: unable to verify the first certificate in nodejs 通过SSL托管在IIS上的NodeJS Express API返回错误:无法验证第一个证书 - NodeJS Express API hosted on IIS over SSL returns Error: unable to verify the first certificate 无法验证第一个证书 - Unable to verify the first certificate 无法验证第一个证书; NodeJs 与 Python 请求 - Unable to verify the first certificate; NodeJs vs Python Requests 错误:无法验证nodejs中的第一个证书azure队列存储createMessage - Error: unable to verify the first certificate in nodejs azure queue storage createMessage stompit 是 nodejs 模块无法连接并出现错误“”无法验证第一个证书” - stompit is nodejs module failed to connect with error “”Unable to verify the first certificate" Nuxt Js Laravel API 无法验证第一个证书 - Nuxt Js Laravel API Unable to verify first certificate SwagQL - 无法验证第一个证书 - SwagQL - Unable to verify the first certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM