gpt4 book ai didi

node.js - 在最新的 Node 和 NPM 下,Express 服务器的 SSL 握手失败

转载 作者:IT老高 更新时间:2023-10-28 23:21:59 25 4
gpt4 key购买 nike

我将 Mac 上的 Node.js 升级到了最新的 0.12.4,并将 NPM 升级到了 2.10.1,并为我的 Express 项目重新运行了 npm install。

现在,当我访问 https://localhost:3001 时,我在 Chrome 中收到“此网页不可用/ERR_CONNECTION_REFUSED”。当我运行 curl -v https://localhost:3001 我得到

curl -v https://localhost:3001/
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 3001 (#0)
* Server aborted the SSL handshake
* Closing connection 0
curl: (35) Server aborted the SSL handshake

这绝对是升级 Node.js 的结果,升级后立即出现问题。

我这样开始我的服务:

options = {
key: fs.readFileSync('sslkey.pem'),
cert: fs.readFileSync('sslcert.pem')
};
http.createServer(app).listen(settings.apiPort);
https.createServer(options, app).listen(settings.apiSSLPort);
console.log('Listening on ports: ' + settings.apiPort + ' and ' + settings.apiSSLPort);

有没有人知道是什么导致了这个问题?

最佳答案

我遇到了同样的问题,试试这个:

options = {
key: fs.readFileSync('sslkey.pem', 'utf-8'),
cert: fs.readFileSync('sslcert.pem', 'utf-8'),
ca: fs.readFileSync(<CA_FILE>, 'utf-8'),
requestCert: true,
rejectUnauthorized: false
};

关于node.js - 在最新的 Node 和 NPM 下,Express 服务器的 SSL 握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30488151/

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