androidflutterdartsslpost

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


Solution

  • 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.