Home > Enterprise >  Handshake error in flutter while loading image via cached_image_network
Handshake error in flutter while loading image via cached_image_network

Time:08-26

CacheManager: Failed to download file from https://gorealestates.com/storage/products/thumb/Property_119989_72753174907.png with error: I/flutter (19986): HandshakeException: Handshake error in client (OS Error: I/flutter (19986): CERTIFICATE_VERIFY_FAILED: Hostname mismatch(handshake.cc:393)) I/flutter (19986): CacheManager: Failed to download file from https://gorealestates.com/storage/products/thumb/1661318454_plots-in-siktaur-gorakhpur.jpg with error: I/flutter (19986): HandshakeException: Handshake error in client (OS Error: I/flutter (19986): CERTIFICATE_VERIFY_FAILED: Hostname mismatch(handshake.cc:393))

CodePudding user response:

In order to enable this option globally in your project, here is what you need to do:

1.In your main.dart file, add or import the following class:

 class MyHttpOverrides extends HttpOverrides{
  @override
  HttpClient createHttpClient(SecurityContext? context){
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
  }
}
  1. In your main function, add the following line after function definition:

HttpOverrides.global = MyHttpOverrides();

This comment was very helpful to pass through this matter, and please note that...

This should be used while in development mode, do NOT do this when you want to release to production, the aim of this answer is to make the development a bit easier for you, for production, you need to fix your certificate issue and use it properly, look at the other answers for this as it might be helpful for your case.

CodePudding user response:

These are related to image host server not client.

  • Related