79441665

Date: 2025-02-15 14:18:05
Score: 6.5 🚩
Natty: 4
Report link

class MyHttpOverrides extends HttpOverrides { final String cert;

MyHttpOverrides(this.cert);

@override HttpClient createHttpClient(SecurityContext? context) { final SecurityContext securityContext = SecurityContext(withTrustedRoots: false); securityContext.setTrustedCertificatesBytes(cert.codeUnits); return super.createHttpClient(securityContext) ..badCertificateCallback = (X509Certificate cert, String host, int port) => true; }

I call this in main.dart:

final cert = await rootBundle.loadString('assets/certificates/dev-cert.pem'); HttpOverrides.global = MyHttpOverrides(cert);

I used this method but sometimes it works and sometimes it doesn't. Now it doesn't work anymore. I think maybe the certificate file has changed. please help me

Reasons:
  • Blacklisted phrase (1): help me
  • RegEx Blacklisted phrase (3): please help me
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @override
  • Low reputation (1):
Posted by: ziba amri