How to Communicate with a Server Using a Self-Signed Certificate (My Own CA) Without Errors in Flutter's HTTP Client

Flutter
2021-03-12 11:02 (3 years ago) ytyng

Write this somewhere

class DevHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
  }
}

HttpOverrides.global = new DevHttpOverrides();

https://stackoverflow.com/questions/59622087/flutter-https-with-self-signed-certificate

Current rating: 5

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011