'badCertificateCallback' for CronetClient and CupertinoClient

22 Views Asked by At

Previously I was using the regular http.Client from the dart http package. I had implemented the following to allow any certificate in debug mode:

class BadCertificateHttpOverrides extends io.HttpOverrides {
  @override
  io.HttpClient createHttpClient(io.SecurityContext? context) {
    bool callback(io.X509Certificate cert, String host, int port) => true;

    return super.createHttpClient(context)..badCertificateCallback = callback;
  }
}
if (kDebugMode) {
  // Override to allow arbitrary certificates in debug mode
  io.HttpOverrides.global = BadCertificateHttpOverrides();
}

However, I've now started using the CronetClient and the CupertinoClient on Android and iOS respectively, as suggested by the http package's documentation, and this no longer works.

Is there a similar way for both these implementations to allow arbitrary certificates in debug mode?

0

There are 0 best solutions below