android – Trust user-added CA certificates in Flutter application


I’m writing flutter app that will retrieve data via https from a local server. We have our own certification authority and have installed the certificate on the server. We also installed the intermediate certificate on the Android device so it can be trusted. When connecting to our server in chrome SSL works fine and the browser trusts our CA.
But when I try to connect to it in the app, I get this error:

E/flutter (15518): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error: E/flutter (15518): CERTIFICATE_VERIFY_FAILED: self signed certificate in certificate chain(handshake.cc:393)) E/flutter (15518): #0 _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46) E/flutter (15518): #1 _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:142:25) E/flutter (15518): #2 _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:911:54) E/flutter (15518): #3 _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1040:19) E/flutter (15518): <asynchronous suspension> E/flutter (15518):

I’ve followed this guide and configured the Android manifest like this and created a network_security_config.xml file
AndroidManifest.xml
network_security_config.xml
It can be reproduced in a new Flutter project.
Has anyone encountered a similar problem? We checked our certificates and they are ok. It also works for Chrome on the same device. I checked the Chrome app manifest and we have the same network security configuration

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img