如何编写安全套接字IO客户端

是否有任何文档或例如如何编写一个socket.io客户端连接到一个socket.io服务器安全(encryption连接,不只是纯文本令牌authentication )?

下面的代码显示了如何创build服务器,我可以使用“ curl –cacert ssl_cert.pem https:// localhost ”来testing服务器是否启动:

// declarations var fs = require('fs'); var io; var app; var httpsServ = require('https'); var host = "localhost"; var port = 443; var processRequest = function (req, res) { // empty method } // create httpsServ app = httpsServ.createServer({ // server SSL key/cert files key: fs.readFileSync("ssl_key.pem"), cert: fs.readFileSync("ssl_cert.pem") }, processRequest).listen(port); // create io socket server io = require('socket.io').listen(app, function () { console.log("Server started and running " + host + ":" + port); }); // implement request/response io.sockets.on('connection', function (socket) { socket.on("ClientRequest", function (data) { // handle client request }); }); // ...etc 

先谢谢你 :)

       

网上收集的解决方案 "如何编写安全套接字IO客户端"