我在我的 Mac 上将 Node.js 升级到最新版本 0.12.4,同时将 NPM 升级到2.10.1,然后重新运行 Express 项目的 npm install 命令。
现在,在 Chrome 中访问 https://localhost:3001 时,会显示“该网页不可用/ 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);
有人有任何想法是什么原因导致这个问题吗?
curl -k -v https://localhost:3001/
显示了什么?-k
选项告诉curl
忽略安全警告,继续连接。这个选项和-v
一起使用,可以提供更多关于服务器证书的信息。或者,您也可以使用openssl s_client -connect localhost:3001
命令。有趣的部分是确定在 SSL 握手期间何时关闭连接。 - Castaglia