node.js - 加载资源失败: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 和私钥并使用它们。
我在这里做错了什么?
解决方案
--首先,右键单击您计算机的时间,然后选择“调整日期/时间”选项。--“同步你的时钟”下的“立即同步”,然后点击它。因此,您的系统正在同步您的计算机时钟。看看:https ://kinsta.com/knowledgebase/neterr-cert-authority-invalid/
推荐阅读
- java - 如何将数组列表中的对象相乘?
- python - 为什么我的堆栈代码适用于基本情况,但不适用于较长的列表?
- typescript - 类型 '{ $route(currentRoute: any): void; 上不存在属性 }' 在 Ionic Vue 中
- c++ - 这是一个分而治之的算法吗?
- rust - 与 Embedded rust 中的对象通信。例如,从中断处理程序中调用方法
- c# - 使用 C# 创建猜谜游戏的二进制搜索
- windows - 使用远程服务器上的 Airflow 从 Windows 共享文件夹中读取文件?
- netsuite - NetSuite SuiteScript - 多源文件包含
- c - 除了 Lex 或 Bison 中的特定字符串之外,如何解析字符?
- powershell - 将单个值从 SQL 查询传递到 PowerShell 变量