我正在尝试使用ws library使用nodejs连接安全的websocket。服务器也使用相同的ws库。
我的ios和chrome webapp能够连接到安全的websocket 但是当我尝试通过基于Linux的系统进行连接时,会抛出错误:
events.js:74
throw er; // Unhandled 'error' event
^
Error: CERT_UNTRUSTED
at SecurePair.<anonymous> (tls.js:1289:32)
at SecurePair.EventEmitter.emit (events.js:94:17)
at SecurePair.maybeInitFinished (tls.js:896:10)
at CleartextStream.read [as _read] (tls.js:430:15)
at CleartextStream.Readable.read (_stream_readable.js:304:10)
at EncryptedStream.write [as _write] (tls.js:344:25)
at doWrite (_stream_writable.js:250:12)
at writeOrBuffer (_stream_writable.js:237:5)
at EncryptedStream.Writable.write (_stream_writable.js:184:11)
at write (_stream_readable.js:557:24)
我的代码段是:
/*Websocket client ; gateway will intiate the connection to cloud*/
var WebSocket = require('ws');
var connection_client = new WebSocket('wss://IP:1337/macadd=' + process.argv[2] +'&platform=gateway'
);
任何帮助都将非常感激。
答案 0 :(得分:0)
CERT_UNTRUSTED
可能意味着您使用的是未受信任的自签名证书。为HTTPS和WSS添加相同的证书,以便浏览器可以提示用户信任它。