从iojs升级到Nodejs v4.4.4后,自签名SSL不起作用
我在应用程序中使用iojs和koa,最近我决定将iojs更新为nodejs v4.4.4。更新非常顺利,我的应用程序立即运行。问题是我在开发机器上使用了自签名SSL证书,更新到nodejs后,当我尝试访问网站时收到以下消息:
该网站无法提供安全的连接
本地主机使用不受支持的协议。
ERR_SSL_VERSION_OR_CIPHER_MISMATCH
The client and server don't support a common SSL protocol version or cipher suite. This is likely to be caused when the server needs RC4, which is no longer considered secure.
I am using nvm
so I tried switching to iojs and the website was working again.
After some reading I found out that I have to update the openssl
to version 1.0.2g
instead of the 1.0.1g
that I used to create the .key
and .crt
files. So I updated openssl
and generated new key and certificate files like this:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
Sadly this did not resolve the issue.
This is the code that I use to setup the https on the server:
let sslOptions = {
key: fs.readFileSync('/etc/apache2/ssl/apache.key'),
cert: fs.readFileSync('/etc/apache2/ssl/apache.crt')
};
let server = require('https').createServer(sslOptions, app.callback())
Am I doing something wrong? Why does it work with iojs and does not work with nodejs?
感谢您的回答!
正如我所怀疑的那样,问题出在与openssl无关的东西上。
在我的应用程序中,我有一个
config.js
带有应用程序配置的文件。在其中,我正在读取证书文件,并将其添加到javascript对象中。问题是,我正在使用该
lodash
模块合并2个javascript对象(其中一个包含证书文件)。我使用的是
lodash
模块的旧版本,看来它使用Buffer
来合并文件。该Buffer
版本中的Buffer
实现与新Node.js
版本中的实现不匹配。这导致证书文件的错误合并,并导致ERR_SSL_VERSION_OR_CIPHER_MISMATCH
错误消息。长话短说,将
lodash
模块更新到最新版本后,证书开始按预期工作。我不是NodeJS专家。但是似乎您需要在节点服务器上禁用RC4。我认为这就是问题所在。
将有一个信任库(密钥库)文件,其中需要注册所有受信任的证书。您将必须在此注册此新创建的证书。客户端使用该信任库文件来检查证书是否可以信任。
有关更多详细信息,您可以从以下链接获取参考:-
创建自签名证书(openssl和keytool)
希望对您有所帮助。
根据错误消息判断,自签名证书没有问题。但是提供ssl连接的“服务器”不支持协议版本和密码套件的适当组合。
或更详细
可能会告诉您ssl握手期间出了什么问题。
您还可以找出称为sslscan的工具提供了哪些组合
最后,您将需要通过提供更多ssloptions配置您的https服务器提供的密码套件。
看到这里https://certsimple.com/blog/a-plus-node-js-ssl
你的回答