A colleague has given me a Flutter project to try to build the app in iOS (I use a Mac, we both use Android Studio). Everything is ok except for this error:
Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:363))
If I use HTTP instead of HTTPS it works obviously. My colleague said he solved by adding this line of code:
client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
This line of code is also in my project because the source is the same. So why does it work on Android, but not on iOS?
The problem is still going more than 1 year after this, it's not a problem with android because i can go the website and the certificate is ok, but when i use flutter to get there there's the error. I was forced to add the certificate manually but doing an update everytime we have a new customer would be really painful for our workflow.
In some cases, you must check the date and time on your device, they need to be synchronized with the actual time and date, otherwise, cause of the handshake error. Sorry, something went wrong.
Sorry, something went wrong. I found the problem.. SSLCertificateChainFile config is missing on Apache server side.. This usually works fine, as most client systems have a large store of certificates... but for some reason, it does not work for android simulator and android device...
As previously mentioned in the comments, the HTTP request gets through since it returns a 405 error. HTTP error 405 usual points is usually defined as "Method not allowed", and commonly caused by incorrect request method. You may want to check with the server if it can receive the request that you're sending.
Old question but my solution was to ensure the time/date set correctly on client
best way for ssl certification problem on all http requests
it is work on both platform (android & ios)
class MyHttpOverrides extends HttpOverrides{
@override
HttpClient createHttpClient(SecurityContext context){
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
}
}
void main(){
HttpOverrides.global = new MyHttpOverrides();
runApp(new MyApp());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With