Hi,
how we can disable the certificate verify ? Because in local / dev we have a self signed certificate and it make an error (indicate in the title of the issue).
I can't make a real certificate in a local server (symfony server) so i'm blocked if i can't disabled this control.
First, Having self-signed certificate is not recommended beacuse it's not secured.
For Production, A certificate chain must be added to server configuration which allows your app can access server through api requests.
For Development, you can proceed in 2ways.
class MyHttpOverrides extends HttpOverrides{
@override
HttpClient createHttpClient(SecurityContext context){
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
}
}
b. Call the above class in main() method as first statement
main(){
HttpOverrides.global = new MyHttpOverrides();
runApp(widget)
}
Solution no. 2 provided by @venkatesh-u works for me but what I couldn't understand that this issue occurs at only old Android Devices like Samsung Galaxy Grand 2 and Samsung A5 etc. ? Not for other devices with the latest Operating System.
This given solution did the trick for me also. Considering that Flutter is soon forcing https-connections, it would still be nice if this would work in a more obvious way (e.g, the Client() call could consume an optional onHandshakeError callback)
Most helpful comment
First, Having self-signed certificate is not recommended beacuse it's not secured.
For Production, A certificate chain must be added to server configuration which allows your app can access server through api requests.
For Development, you can proceed in 2ways.
a. Create a file with dart extensionand then dump the below code into it
class MyHttpOverrides extends HttpOverrides{
@override
HttpClient createHttpClient(SecurityContext context){
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
}
}
b. Call the above class in main() method as first statement
main(){
HttpOverrides.global = new MyHttpOverrides();
runApp(widget)
}