Open mryogi1976 opened 2 years ago
So to sum it up:
main.dart
:
Future<void> loadCerts() async {
final certs = [
'assets/ca/lets-encrypt-r3.pem'
];
for (var cert in certs) {
final certBytes = await PlatformAssetBundle().load(cert);
SecurityContext.defaultContext.setTrustedCertificatesBytes(certBytes.buffer.asUint8List());
}
}
pubspec.yaml
:
flutter:
assets:
- assets/ca/
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
}
}
Please try the below
final ioc = new HttpClient(); ioc.badCertificateCallback = (X509Certificate cert, String host, int port) => true; Client _client = IOClient(ioc); _client.get(url);
badCertificateCallback
is rather nasty workaround - not a solution to the real problem IMHO
lehttp_overrides
package solved this issue for me.
A Flutter package to resolve Let's Encrypt SSL certificate problems with Android 7.1.1 and below
It adds the ISRG Root X1
certificate to the set of trusted X509 certificates.
HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:359))
I have 4 apps live on Google Play Store from last few months , yesterday all stopped working because of above error.
I did not understand the cause of above error and no solution found til now.
Could anybody suggest. I am using http: ^0.13.3 in my one of the app , It comes in http.post method.