[英]LetsEncrypt root certificate expiry breaks Azure Function Node application
我有一个运行为 Azure function 的节点应用程序。每 60 秒它会进行一次 web api 调用,web api 之一的 SSL 证书由 LetsEncrypt (R3) 签名。
2021 年 9 月 30 日,根证书到期。 https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
现在 function 无法调用 API。(请参阅下面的错误)。
错在哪里?
我尝试在我自己的机器上运行类似的代码并遇到类似的问题,即使在从 Windows 证书存储中删除所有过期的证书之后也是如此。
这是在 Azure Function 应用程序中抛出的错误:
Result: Failure Exception: AggregateError: RequestError: certificate has expired
at ClientRequest.<anonymous> (C:/home/site/wwwroot/node_modules/got/dist/source/core/index.js:953:111)
at ClientRequest.origin.emit (C:/home/site/wwwroot/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20) RequestError: certificate has expired
at ClientRequest.<anonymous> (C:/home/site/wwwroot/node_modules/got/dist/source/core/index.js:953:111)
at ClientRequest.origin.emit (C:/home/site/wwwroot/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20) Stack: AggregateError: RequestError: certificate has expired at ClientRequest.<anonymous>
真正的触发因素是我的第一个电话
import { Issuer } from 'openid-client';
// ...
// This line of code throws the exception
const laqorrIssuer = await Issuer.discover(clientMetaData.laqorr_api_base);
如果您需要让您的 Node 应用程序紧急运行,只需在开头添加这行代码即可。
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
这将完全禁用证书验证。 显然,这不是一个可以接受的长期解决方案。
这是我在四处摸索时想出的更多信息。
让加密
Lets Encrypt 最初使用特定证书作为根证书颁发机构: DST Root CA X3 。 它的有效范围是从 2000-10-01 到 2021-10-01。 它不再有效。
Lets Encrypt 现在使用ISRG Root X1作为根证书颁发机构。 它的有效日期范围为 2015-06-04 到 2035-06-04。 如果一个平台不承认这个根证书颁发机构,它就不会信任 Lets Encrypt。
节点
更新操作系统中的证书存储不会对 NodeJS 平台产生影响。
Node 使用硬编码的证书颁发机构列表,定义在node_root_certs.h中。 (有关详细信息,请参阅此自述文件)。
最新的证书ISRG Root X1
自版本8.0.0
以来一直是 Node 的一部分。 (请参阅此提交)。
const got = require('got'); (async () => { try { // Change this to the url you want to test const url = 'https://letsencrpt.org'; console.log(`Reading from ${url}`); const response = await got(url); console.log(response.body); } catch (error) { console.log(`error: ${error}`); if(error.response) { console.log(error.response.body); } } })();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.