websocket连接wss,虚拟机正常,真机居然出错,
WebSocket.connect(url)一直提示错误:
HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393)
)
证书不被信任?
那我们来强制信任证书
//强制信任证书
HttpClient httpClient = HttpClient();
httpClient.badCertificateCallback = (X509Certificate cert, String host, int port){
return true;
};
WebSocket.connect(url,customClient: httpClient)
网友评论