Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter HTTPS Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:363))

A colleague has given me a Flutter project to try to build the app in iOS (I use a Mac, we both use Android Studio). Everything is ok except for this error:

Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:363))

If I use HTTP instead of HTTPS it works obviously. My colleague said he solved by adding this line of code:

client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;

This line of code is also in my project because the source is the same. So why does it work on Android, but not on iOS?

like image 208
Gabriele Guccione Avatar asked Feb 28 '19 14:02

Gabriele Guccione


People also ask

Is flutter certificate still a problem with Android?

The problem is still going more than 1 year after this, it's not a problem with android because i can go the website and the certificate is ok, but when i use flutter to get there there's the error. I was forced to add the certificate manually but doing an update everytime we have a new customer would be really painful for our workflow.

Why do I get a handshake error on my Device?

In some cases, you must check the date and time on your device, they need to be synchronized with the actual time and date, otherwise, cause of the handshake error. Sorry, something went wrong.

Is sslcertificatechainfile config missing on Apache server side?

Sorry, something went wrong. I found the problem.. SSLCertificateChainFile config is missing on Apache server side.. This usually works fine, as most client systems have a large store of certificates... but for some reason, it does not work for android simulator and android device...

Why is my HTTP request returning a 405 error?

As previously mentioned in the comments, the HTTP request gets through since it returns a 405 error. HTTP error 405 usual points is usually defined as "Method not allowed", and commonly caused by incorrect request method. You may want to check with the server if it can receive the request that you're sending.


2 Answers

Old question but my solution was to ensure the time/date set correctly on client

like image 172
Vince Lowe Avatar answered Oct 29 '22 15:10

Vince Lowe


best way for ssl certification problem on all http requests

it is work on both platform (android & ios)

class MyHttpOverrides extends HttpOverrides{
  @override
  HttpClient createHttpClient(SecurityContext context){
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
  }
}

void main(){
    HttpOverrides.global = new MyHttpOverrides();
    runApp(new MyApp());
}
like image 45
Kiax Avatar answered Oct 29 '22 15:10

Kiax