如何在 Node.js Express 服务器上阻止 TLS 1.0 和 TLS 1.1?我正在使用传统的服务器设置脚本:
const app = express();
export const server = app.listen(3000);
我有点困惑为什么我找不到这方面的任何文档。
通常,您会在其他东西后面运行 Express 服务器,例如 Nginx 代理、AWS 负载均衡器或终止 TLS 的其他软件或硬件。在您的示例中,您根本没有通过 HTTPS 进行侦听,而是在端口 3000 上侦听 HTTP 连接。配置通常在 Node 应用程序外部完成,但如果您确实想在 Node 应用程序中执行此操作,会是这样的:
const express = require('express')
const https = require('https')
const fs = require('fs')
const { options } = require('crypto')
const app = express()
const opts = {
key: fs.readFileSync('/path/to/key.pem'),
cert: fs.readFileSync('/path/to/chain.pem'),
secureOptions: constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1,
}
// other app logic
// Or 443 if you run it as root, which is not recommended;
// instead you should proxy to it.
https.createServer(opts, app).listen(3443)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)