Socket.io + SSL + 自签名 CA 证书在连接时出错

Socket.io + SSL + 自签名 CA 证书在连接时出错

问题描述:

我正在使用使用自签名 CA 证书创建的证书运行 https 服务器.

I am running an https server using a certificate which was created using a self-signed CA certificate.

现在我想将 Socket.io 客户端连接到连接到 https 服务器的 Socket.io 服务器.不幸的是,我收到一个错误,告诉我:

Now I want to connect Socket.io client to the Socket.io server that is attached to the https server. Unfortunately, I get an error, telling me:

Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
    at SecurePair.<anonymous> (tls.js:1271:32)
    at SecurePair.EventEmitter.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:883:10)
    at CleartextStream.read [as _read] (tls.js:421:15)
    at CleartextStream.Readable.read (_stream_readable.js:293:10)
    at EncryptedStream.write [as _write] (tls.js:330:25)
    at doWrite (_stream_writable.js:211:10)
    at writeOrBuffer (_stream_writable.js:201:5)
    at EncryptedStream.Writable.write (_stream_writable.js:172:11)
    at write (_stream_readable.js:547:24)
    at flow (_stream_readable.js:556:7)

基本上,此错误告诉我无法成功验证证书.这是因为相应的 CA 证书是自签名的.使用 https 请求时,我可以指定我信任的 CA.

Basically, this error tells me that the certificate could not be verified successfully. This is due to the fact the the according CA certificate is self-signed. When using a https request, I can specify CAs whom I trust.

在这种情况下如何连接 Socket.io?

How can I make Socket.io connect in this case?

PS:我正在运行 Node.js 0.10.0 和 Socket.io 0.9.13.

PS: I am running Node.js 0.10.0 and Socket.io 0.9.13.

不要使用自签名证书.只是不要,某些浏览器在使用 WebSockets 时无法让您接受它们.而且你看起来像一个没有购买适当证书的廉价d * ck.

Don’t use self signed certificates. Just don’t, some browsers give you no way of accepting them when using WebSockets. And you look like a cheap d*ck for not buying a proper cert.

来自 他们看到我花粉,他们讨厌(第 23 页).Socket.IO 核心团队成员 Arnout Kazemier (3rdEden) 的演讲.

From They see me pollin, they hatin (p. 23). A presentation by Arnout Kazemier (3rdEden), core team member of Socket.IO.