1

I'm trying to get an api from www.mocky.io, the issue is, when the app starts I'm getting an error like

E/flutter ( 846): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error: E/flutter ( 846): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354))

this is how I'm getting the response.

  Future _fetchPost() async {
http.Response response = await http.get(url);

print(response.body);

setState(() {
  var convertDatatoJson = json.decode(response.body);
  debugPrint(convertDatatoJson.toString());
  _data = convertDatatoJson['table_menu_list'];
});}

How can I verify the certificate for this api link for GET method?

I referred this issue, for POST method https://stackoverflow.com/a/54359013/11893608,

any other suggestions would be helpful

AllwiN
  • 693
  • 2
  • 12
  • 26

2 Answers2

1

Change https to http

it will Resolve your Issue

Use this : http://www.mocky.io/v2/5dfccffc310000efc8d2c1ad

Arun R. Prajapati
  • 2,654
  • 1
  • 14
  • 14
1

Try adding both http and www.

Example:

http://www.mocky.io/v2/5185415ba171ea3a00704eed

mocky.io may be using www to differentiate between subdomains. That is why its not worked when adding http only.

Crazy Lazy Cat
  • 13,595
  • 4
  • 30
  • 54
  • Thank you for saying this specifically but I need the certification to be ignored while calling the api. Is there any way? upvoted(); – AllwiN Dec 30 '19 at 11:44
  • @AllwiN I don't know how to ignore this with `http` package. But you can do it by directly using `HttpClient` class. See [here](https://stackoverflow.com/questions/46135757/ssl-handshake-error-on-self-signed-cert-in-flutter) – Crazy Lazy Cat Dec 30 '19 at 11:48