1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] 'badCertificateCallback' for CronetClient and CupertinoClient

Discussão em 'Mobile' iniciado por Stack, Outubro 7, 2024 às 08:02.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página