Karol Wiśniewski
Karol Wiśniewski

Reputation: 518

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

Upvotes: 4

Views: 13404

Answers (1)

Arjun Ranjith
Arjun Ranjith

Reputation: 254

Try this one

   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(MyApp());
}

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

Upvotes: 7

Related Questions