how to solve flutter CERTIFICATE_VERIFY_FAILED error while performing a POST request?

前端 未结 8 1383
孤街浪徒
孤街浪徒 2020-11-27 19:54

I am sending a post request in Dart. It is giving a response when I test it on API testing tools such as Postman. But when I run the app. It gives me the following error:- <

8条回答
  •  孤街浪徒
    2020-11-27 20:50

    Use tls 1.3 request URL, no problem. Example

    import 'dart:io';
    
    main() async {
      HttpClient client = new HttpClient();
      // tls 1.2 error
    //  var request = await client.getUrl(Uri.parse('https://shop.io.mi-img.com/app/shop/img?id=shop_88f929c5731967cbc8339cfae1f5f0ec.jpeg')); 
      // tls 1.3 normal
      var request = await client.getUrl(Uri.parse('https://ae01.alicdn.com/kf/Ud7cd28ffdf6e475c8dc382380d5d1976o.jpg'));
      var response = await request.close();
      print(response.headers);
      client.close(force: true);
    }
    

提交回复
热议问题