gpt4 book ai didi

node.js - NodeJs "Forward Secrecy"问题

转载 作者:太空宇宙 更新时间:2023-11-03 13:13:56 27 4
gpt4 key购买 nike

我试图在 ssllabs.com 上为我的网站 www.cloudcaptcha.ga 获得 A+ 分数,但收到此警告:'此服务器不支持引用浏览器的前向保密。等级上限为 B'

我正在使用带有 http2 服务器模块的 NodeJs v12.6。使用

生成有效的 dhparam

openssl dhparam -outform PEM -out dhparam.pem 2048

但这并没有帮助。

我当前服务器的 secureContextOptions =

{
ca: fs.readFileSync('chain.pem'),
cert: fs.readFileSync('fullchain.pem', 'utf8'),
key: fs.readFileSync('privkey.pem', 'utf8'),
dhparam: fs.readFileSync('dhparam.pem', 'utf8'),
rejectUnauthorized: false,
honorCipherOrder: false,
allowHTTP1: true,
ecdhCurve: 'auto',
}

如何解决这个前向保密问题?

最佳答案

前向保密问题可能是由禁用的 honorCipherOrder 选项引起的,请尝试启用它。

honorCipherOrder: true

当禁用honorCipherOrder 时,将根据 TLS 客户端首选项选择握手期间协商的密码套件。有 TLS 客户端,例如 IE 11 / Win Phone 8.1比 FS 密码套件更喜欢非 FS 密码套件。

为了获得A+,它也是required添加 Strict-Transport-Security (HSTS) header 到每个响应的最大年龄至少为 6 个月:

New grade A+ is introduced for servers with exceptional configurations. At the moment, this grade is awarded to servers with good configuration, no warnings, and HTTP Strict Transport Security support with a max-age of at least 6 months.

max-age 设置为 1 年的 HSTS header 示例:

Strict-Transport-Security: max-age=31536000;

使用 native node.js 响应对象,您可以使用 response.setHeader 设置标题:

response.setHeader("Strict-Transport-Security", "max-age=31536000");

如果您使用 express ,您还可以查看 helmet或者只是编写一个简单的中间件,将 header 添加到每个响应。

关于node.js - NodeJs "Forward Secrecy"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57233215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com