Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trust user-added CA certificates in Flutter application #140737

Closed
Malnen opened this issue Dec 29, 2023 · 3 comments
Closed

Trust user-added CA certificates in Flutter application #140737

Malnen opened this issue Dec 29, 2023 · 3 comments
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@Malnen
Copy link

Malnen commented Dec 29, 2023

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

Android Manifest

<application
  android:networkSecurityConfig="@xml/network_security_config"
  ...

Network Security Config

<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>

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. We also cannot addour certificates inside the application because there may be an unlimited number of other CAs in production that we want to trust. We want to trust all certificates added by the user

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jan 2, 2024
@darshankawar
Copy link
Member

@Malnen
Can you check this similar issue and confirm if it resembles your case or not ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 2, 2024
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

Copy link

github-actions bot commented Feb 6, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

2 participants