我正在使用使用nodejs的https服务器。出于安全原因,我必须更改某些 ssl 参数。更具体地说,我必须设置/禁用“客户端重新协商限制”。
根据标准文档 here ,我必须将 tls.CLIENT_RENEG_LIMIT 设置或更改为我的值。
由于我使用 https 模块,因此我可以访问 https 服务器。我的问题是如何从https服务器获取tls对象,以便我可以设置值。
我知道我可以在创建 https 服务器时设置一些选项,如下所示。
const options = {
key: fs.readFileSync('app-key.pem'),
cert: fs.readFileSync('app-cert.pem'),
secureOptions: constants.SSL_OP_NO_SSLV2 | ...,
ciphers: [...]
}
但是,如果我要为 tls.CLIENT_RENEG_LIMIT 或 tls.CLIENT_RENEG_WINDOW 等添加值,我不确定到底要设置什么。我假设有某种方法可以获得 tls 句柄,通过它我可以设置这些值。
这里有什么帮助吗...?
最佳答案
您无法获取 TLS
来自 https 服务器对象的对象,但您可以使用内置模块 tls
设置所需的选项。创建之前https
服务器,您可以将值设置为:
const tls = require('tls')
tls.CLIENT_RENEG_LIMIT = ' required value'
const options = {
key: fs.readFileSync('app-key.pem'),
cert: fs.readFileSync('app-cert.pem'),
secureOptions: constants.SSL_OP_NO_SSLV2 | ...,
ciphers: [...]
}
const server = https.createServer(options,function(req,res){
res.writeHead(200);
res.end('hello world\n');
})
server.listen(8080);
TLSv1.3 does not support renegotiation.
https
模块依赖于tls
,所以无论您设置为 tls
的有效值如何将适用于https
You can not pass
CLIENT_RENEG_LIMIT
ashttps
options becauseoptions <Object>
Accepts options fromtls.createServer()
,tls.createSecureContext()
andhttp.createServer()
.
关于node.js - Nodejs如何从https服务器获取TLS对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59908809/