We are using Flutter for app development. Our security testers said that we need to disable SSL Pinning in Flutter code so they can run some test. We couldn't do it. We use Dio package for HTTP request. How can we disable SSL Pinning on Flutter?
We are using Flutter for app development. Our security testers said that we need to disable SSL Pinning in Flutter code so they can run some test. We couldn't do it. We use Dio package for HTTP request. How can we disable SSL Pinning on Flutter?
EDIT:
SSL Pinning is not the default behavior. So you don't need to disable it if it had not already been enabled.
I faced a similar problem. The solution was pretty simple. The http packet automatically prevents the network from listening.
To fix this problem and resubmit it for penetration testing, make these changes to the main.dart file:
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
if (Platform.isAndroid) {
return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
}
return super.createHttpClient(context)
..findProxy = (uri) {
return "PROXY localhost:8080";
}
..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
}
}
and add this line in main() method:
HttpOverrides.global = MyHttpOverrides();