简体   繁体   English

节点 - 无法验证第一个证书/UNABLE_TO_VERIFY_LEAF_SIGNATURE localhost

[英]Node - Unable to Verify the First Certificate / UNABLE_TO_VERIFY_LEAF_SIGNATURE localhost

I have an ASP.NET Core 3.1 web app that I run on my local development machine.我有一个在本地开发机器上运行的 ASP.NET Core 3.1 Web 应用程序。 This app successfully runs.此应用程序成功运行。 I can also successfully execute requests to it via Postman.我也可以通过 Postman 成功执行对它的请求。 I'm trying to run a test from a Node.js app.我正在尝试从 Node.js 应用程序运行测试。 This app is using Axios to try to load one of the web pages.此应用程序正在使用Axios尝试加载其中一个网页。 The request looks like this:请求如下所示:

const result = await axios.get('https://localhost:5001/');

When this request runs, I receive the following error:当此请求运行时,我收到以下错误:

Error: unable to verify the first certificate
...
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
...

The fact that I can a) load the url in my browser and b) run the request from Postman leads me to believe there is a config issue with my Node app.我可以 a) 在浏览器中加载 url 和 b) 运行来自 Postman 的请求这一事实让我相信我的 Node 应用程序存在配置问题。 I don't know if it's an issue with a) my axios request or b) some app configuration.我不知道这是否是 a) 我的axios请求或 b) 某些应用程序配置的问题。 Oddly, I receive the same error if I try to execute my request against http://localhost:5000/ (ie not over HTTPS).奇怪的是,如果我尝试针对http://localhost:5000/ (即不通过 HTTPS)执行我的请求,我会收到同样的错误。

I'm unsure how to resolve this issue though.我不确定如何解决这个问题。 How do I execute a request via Axios against a web app running on localhost?如何通过 Axios 针对本地主机上运行的 Web 应用程序执行请求?

You'll need to tell axios/node what signing authorities to trust (your browser and postman will already have several of those set up)您需要告诉 axios/node 信任哪些签名机构(您的浏览器和邮递员已经设置了其中的几个)

You do that by configuring the https agent in axios - have a look at this answer for an example : How to configure axios to use SSL certificate?您可以通过在 axios 中配置 https 代理来实现这一点 - 以这个答案为例: 如何配置 axios 以使用 SSL 证书?

And here are instructions on how to get the bundle from the browser (you'll probably need to use a p7b/pfx or get all certs in the chain): https://medium.com/@menakajain/export-download-ssl-certificate-from-server-site-url-bcfc41ea46a2以下是有关如何从浏览器获取捆绑包的说明(您可能需要使用 p7b/pfx 或获取链中的所有证书): https : //medium.com/@menakajain/export-download-ssl -certificate-from-server-site-url-bcfc41ea46a2

暂无
暂无

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

相关问题 在节点中安装自定义SSL证书(UNABLE_TO_VERIFY_LEAF_SIGNATURE) - Installing custom SSL certificate in Node (UNABLE_TO_VERIFY_LEAF_SIGNATURE) 节点js安装npm时出错安装快速代码UNABLE_TO_VERIFY_LEAF_SIGNATURE无法验证第一个证书 - node js Error while installing npm install express code UNABLE_TO_VERIFY_LEAF_SIGNATURE unable to verify the first certificate 对 API 的请求失败,原因:无法验证第一个证书(和 UNABLE_TO_VERIFY_LEAF_SIGNATURE) - Request to API fails, reason: unable to verify the first certificate (and UNABLE_TO_VERIFY_LEAF_SIGNATURE) nodejs - 带有自签名证书的UNABLE_TO_VERIFY_LEAF_SIGNATURE - nodejs - UNABLE_TO_VERIFY_LEAF_SIGNATURE with self-signed certificate 节点肥皂'UNABLE_TO_VERIFY_LEAF_SIGNATURE'错误 - node-soap 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' error Node.js 错误 SSL UNABLE_TO_VERIFY_LEAF_SIGNATURE - Node.js error with SSL UNABLE_TO_VERIFY_LEAF_SIGNATURE 特定情况:UNABLE_TO_VERIFY_LEAF_SIGNATURE - a specific case: UNABLE_TO_VERIFY_LEAF_SIGNATURE NodeJS UNABLE_TO_VERIFY_LEAF_SIGNATURE - NodeJS UNABLE_TO_VERIFY_LEAF_SIGNATURE UNABLE_TO_VERIFY_LEAF_SIGNATURE 来自带有 Firebase 函数 node.js 和证书的请求 (pfx) - UNABLE_TO_VERIFY_LEAF_SIGNATURE from request with Firebase functions node.js with Certificate (pfx) 更新了我的 SSL 证书,但在 AWS EC2 服务器上的 nodejs 中获得了 UNABLE_TO_VERIFY_LEAF_SIGNATURE - Renewed my SSL certificate but getting UNABLE_TO_VERIFY_LEAF_SIGNATURE in nodejs on AWS EC2 server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM