SSL握手在最新的Node& NPM

时间:2015-05-27 16:26:36

标签: node.js ssl express https

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

现在,当我访问https://localhost:3001时,我得到了#34;此网页不可用/ ERR_CONNECTION_REFUSED"在Chrome中。当我运行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);

有没有人有任何想法导致这个问题?

1 个答案:

答案 0 :(得分:2)

我有同样的问题,试试这个:

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
    };