首页 > 解决方案 > 加载资源失败:net::ERR_CERT_AUTHORITY_INVALID

问题描述

我正在通过 https 实现节点 js 脚本。

节点js

const options = {
  key: fs.readFileSync('private.key'),
  cert: fs.readFileSync('cert.crt'),    
  // This is necessary only if using the client certificate authentication.
  requestCert: true,
  rejectUnauthorized: true,

  // This is necessary only if the client uses the self-signed certificate.
  ca: [fs.readFileSync('client-cert.pem')]
};

在每个请求上,这都会给出错误:- ERR_CERT_AUTHORITY_INVALID

我搜索了很多,但没有找到。

我使用以下命令生成客户端密钥:-

openssl req -x509 -newkey rsa:2048 -keyout client-key.pem -out client-cert.pem -days 365

我在服务器上创建 .crt 和私钥并使用它们。

我在这里做错了什么?

标签: node.jsapacheexpresssslsocket.io

解决方案


--首先,右键单击您计算机的时间,然后选择“调整日期/时间”选项。--“同步你的​​时钟”下的“立即同步”,然后点击它。因此,您的系统正在同步您的计算机时钟。看看:https ://kinsta.com/knowledgebase/neterr-cert-authority-invalid/


推荐阅读