美文网首页
域名更换一个证书之后,不被信任

域名更换一个证书之后,不被信任

作者: 晓函 | 来源:发表于2022-04-11 16:42 被阅读0次

    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)
    

    相关文章

      网友评论

          本文标题:域名更换一个证书之后,不被信任

          本文链接:https://www.haomeiwen.com/subject/mwgrjrtx.html