Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhandled Exception: HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393))

I launch my app on older version of Android - 5.1 and I am getting this error:

Unhandled Exception: HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393))

On newer Android like 10 this is not appearing. I am making POST request to my backend, how to fix it?

I found solution: enter link description here

like image 927
Karol Wiśniewski Avatar asked Oct 29 '25 09:10

Karol Wiśniewski


1 Answers

Try this one

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

void main(){
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MyApp());
}

I am not sure about flutter web but it may help flutter ios and android.

like image 192
Arjun Ranjith Avatar answered Oct 30 '25 22:10

Arjun Ranjith