title: CERTIFICATE_VERIFY_FAILED when trying to import data from API
body: <p>I'm trying to learn Flutter/Dart and I'm having to much problems. Now I'm trying to obtain some values from an API. My code is:</p>
  <pre><code>import 'dart:convert';
  import 'package:http/http.dart' as http;
  import 'package:myapp01_apirequest/src/models/uplink_models.dart';
  
  class UplinksProvider{
    String _url       = 'xxx.yyy.com';
  
    Future&lt;List&lt;Uplink&gt;&gt; getEnCines() async{
      try{
        final url = Uri.https(_url, ':14442/api/external/login', {
          'username': 'Joe689',
          'password': '15.Job_1825zz'
        });
  
        final resp = await http.get(url);
        final decodedData = json.decode(resp.body);
        print('Patata');
        print(decodedData);
        
        return [];
      }catch (error){
        print('++++++++++///////++++++++++++++++');
        print(error);
        print('++++++++++*******++++++++++++++++');
      }
    }
  }
  </code></pre>
  <p>Reading the <a href="https://api.dart.dev/stable/2.10.5/dart-core/Uri/Uri.http.html" rel="nofollow noreferrer">Uri constructor</a> documentation I understood that I have to split in 3 my url.</p>
  <ul>
  <li>First one is <code>authority</code>. In my case I think is <code>xxx.yyy.com</code>.</li>
  <li>Second is the <code>unencodedPath</code>. In my case I think is <code>:14442/api/external/login</code>.</li>
  <li>Finally a map with params in my case the username and pass (the only thing I'm pretty sure is correct in my code).</li>
  </ul>
  <p>If I do this, any problem appears, but the <code>print('Patata');</code> and <code>print(decodeData);</code> don't appear. In addition, a file called <code>io_client.dart</code> opens and marks the next line.</p>
  <pre><code>var ioRequest = (await _inner.openUrl(request.method, request.url))
  </code></pre>
  <p>The console shows nothing (I think):</p>
  <pre><code>Launching lib\main.dart on LG M700 in debug mode...
  lib\main.dart:1
  Formato de par�metros incorrecto:
  √ Built build\app\outputs\flutter-apk\app-debug.apk.
  Connecting to VM Service at ws://127.0.0.1:55883/KBAtv2-Jljc=/ws
  </code></pre>
  <p>Why no errors appears but I can't obtain my desired data?</p>
  <hr />
  <p><strong>EDIT:</strong></p>
  <p>According for what @Preet Shah's said I press the &quot;VS run button&quot; and appears the following exception three times:</p>
  <pre><code>I/flutter ( 1932): ++++++++++///////++++++++++++++++
  I/flutter ( 1932): HandshakeException: Handshake error in client (OS Error:
  I/flutter ( 1932):  CERTIFICATE_VERIFY_FAILED: Hostname mismatch(handshake.cc:354))
  I/flutter ( 1932): ++++++++++*******++++++++++++++++
  </code></pre>
  <p>And finally appears:</p>
  <pre><code>I/Choreographer( 1932): Skipped 148531 frames!  The application may be doing too much work on its main thread.
  D/vndksupport( 1932): Loading /vendor/lib/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
  D/vndksupport( 1932): Loading /vendor/lib/hw/gralloc.msm8937.so from current namespace instead of sphal namespace.
  I/Choreographer( 1932): Skipped 35 frames!  The application may be doing too much work on its main thread.
  </code></pre>
  <p>Then the problem is a certification problem, <code>CERTIFICATE_VERIFY_FAILED</code>. As I feel more comfortable with python, I have done some tests to understand the problem. I have been able to verify that this API requires having all the certification verifications in false, otherwise it never leaves the loop. Here is my Python code (just to show what I'm saying).</p>
  <pre><code>import requests
  import json
  
  log_params = {'username': 'Joe689', 'password': '15.Job_1825zz'}
  headers = {'Content-type': 'application/json'}
  url = 'https://xxx.yyy.com:14442/api/external/login'
   
  response = requests.post(url, data=json.dumps(params), headers=self.headers, verify=False)
  finalRes = json.loads(response.text)
  </code></pre>
  <p>As I said, this code is just for me to understand the problem because I am a newbie to Dart. <a href="https://stackoverflow.com/a/54359013/8551424">Here</a> I found this answer and it seems has the solution but I don't know how to implement it, using my <code>Uri.https</code> estructure (maybe it's not possible).</p>
  <p>I tried this, but isn't working:</p>
  <pre><code>Map&lt;String, String&gt; requestHeaders = {
      'Content-type': 'application/json'
  };
  final resp = await http.get(url, headers:requestHeaders);
  </code></pre>
  <p>Thank you very much.</p>