几个连接后,NodeJS + Socket.io SSL失败

时间:2016-09-19 21:12:10

标签: node.js ssl socket.io

我正在使用socket.io运行NodeJS,所有这些都在SSL下。我最近移动了服务器,过去工作正常的东西现在在几分钟后停止工作 - Chrome说连接已重置,curl说存在SSL问题。

我尝试过和没有快递 - 几分钟后都没有成功。

所以 - 我的最小代码是:

var fs = require('fs');
var https = require('https');

const options = {
    key:    fs.readFileSync('XXX.key'),
    cert:   fs.readFileSync('XXX.crt'),
    ca:     fs.readFileSync('XXX.ca')
};

var app = https.createServer(options, function(req, res) {
  res.writeHead(200);
  res.end('(not imporant)\n');
}).listen(3000);

var io = require('socket.io')(app);

如果我注释掉最后一行,服务器总是接受新连接(尽管没有socket.io),一切正常。如果我离开最后一行,它会工作一分钟,各种SSL检查工具都可以,包括:

openssl s_client -connect REDACTED.com:3000
CONNECTED(00000003)
depth=3 /C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
verify error:num=19:self signed certificate in certificate chain
verify return:0
---
Certificate chain
 0 s:/OU=Domain Control Validated/OU=Hosted by XILO Communications Ltd./OU=PositiveSSL Wildcard/CN=*.REDACTED.com
   i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
 1 s:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
   i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
 2 s:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
 3 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
---
Server certificate
-----BEGIN CERTIFICATE-----
REDACTED
-----END CERTIFICATE-----
subject=/OU=Domain Control Validated/OU=Hosted by XILO Communications Ltd./OU=PositiveSSL Wildcard/CN=*.REDACTED.com
issuer=/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
---
No client certificate CA names sent
---
SSL handshake has read 5650 bytes and written 456 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID: 704A23D4B00B3A445A8C9097427FF26B724458F24B105C847B76E576FCA9C803
    Session-ID-ctx:
    Master-Key: 04FB6B5B06954516A073C65A456010C819B157A20F5F308EDCC88C8B0FDCD9A990D3A23AC117714363A92EB56BC98272
    Key-Arg   : None
    Start Time: 1474318665
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

但不久之后(可能是使用该网站的人的几百个客户端连接),相同的命令(来自Mac):

CONNECTED(00000003)
65931:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.60.1/src/ssl/s23_lib.c:185:

来自linux / vagrant:

CONNECTED(00000003)
140236360926880:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 295 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---

curl https://REDACTED:3000给出:

curl: (35) Unknown SSL protocol error in connection to REDACTED:3000

有没有人有任何想法如何克服这个?代码在我们的开发机器上工作正常,但是一旦它进入实时服务器,它就会很快崩溃。

这与我使用通配符证书的事实有关吗?

提前致谢。 编

0 个答案:

没有答案