当前位置:   article > 正文

Dio问题总结_handshake error in client (os error: certificate_v

handshake error in client (os error: certificate_verify_failed: certificate

1. 添加代理

Dio dio = Dio(_options)
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
        (client) {
      client.badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
      client.findProxy = (uri) {
        if (proxyIP == null || proxyIP.isEmpty) {
          return 'DIRECT';
        }
        return 'PROXY $proxyIP:$proxyPort';
      };
      return client;
    };
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

2.CERTIFICATE_VERIFY_FAILED问题

项目运行时报了如下错误:

HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: self signed certificate in certificate chain(handshake.cc:393))
  • 1

解决方法:

Dio dio = Dio(_options)
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
        (client) {
      client.badCertificateCallback = (cert, host, port) {
        return true;
      };
    };
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/145337
推荐阅读
相关标签
  

闽ICP备14008679号