wss/websocket client如何设置rejectUnauthorized: false参数,以忽略证书验证
LinHaoo opened this issue · comments
LinHaoo commented
因为websocket服务器使用的是自签名证书(self-signed certificate),自签名证书不是由受信任的证书颁发机构(CA)签发的,所以需要在客户端忽略证书验证。例如nodejs ws库是这样设置
const WebSocket = require('ws');
const ws = new WebSocket("wss://127.0.0.1:9091", { rejectUnauthorized: false });
ithewei commented
hssl_ctx_opt_t里有个verfiy_peer字段表示是否验证对方证书,默认就是不验证的。
LinHaoo commented
hssl_ctx_opt_t里有个verfiy_peer字段表示是否验证对方证书,默认就是不验证的。
是的,找到了,但是最后调试发现是mbedtls_ssl_handshake返回一个异常错误:SSL - Internal error (eg, unexpected failure in lower-level module,我自己再调试下