CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate using an letsencrypt-signed webserver | flutter

I have spent so many hours just to figure this out. I use wss(secure) for my django websocket. Ive realized that using firebase and firecamp is working perfectly, but in my flutter app websocket connect it does not work. arggg, spending many hours working this error (I initially dont know why the heck is this).

Adding this piece of code in the main.dart file fix my issue. :)

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

void main() async {
  HttpOverrides.global = new MyHttpOverrides();

now its working perfectly :)

Add new comment