Reputation: 336
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?
Upvotes: 1
Views: 135
Reputation: 653
At this time: No, self-signed certificates are not supported on either CupertinoClient
or CronetClient
.
For CupertinoClient
this does not seem to change soon (see https://github.com/dart-lang/http/issues/1178)
For CronetClient
it is at least requested but not commented yet (see https://github.com/dart-lang/http/issues/1314)
Upvotes: 0