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

Support User CAs on Android #66

Closed
denysvitali opened this issue Mar 25, 2024 · 5 comments · Fixed by #72 · May be fixed by #68
Closed

Support User CAs on Android #66

denysvitali opened this issue Mar 25, 2024 · 5 comments · Fixed by #72 · May be fixed by #68
Assignees

Comments

@denysvitali
Copy link
Contributor

For some reason Vikunja doesn't use the system trust store on Android - or at least it doesn't care about the user-provided CAs.

This results in an handshake failure.

I have tried to add a network_security_config file, but this approach doesn't seem to work.

@Benimautner
Copy link
Collaborator

There is an option in the settings called "Ignore certificates" which should help you do what you want to.
I've looked into this in the past and remember not being able to check against the system CA store for some reason.

@denysvitali
Copy link
Contributor Author

Yes, the option "Ignore certificates" works - but it's the wrong solution. I still want to check my certificate, ignoring it makes the communication vulnerable to MITM attack - at this point one could just use plain HTTP, which also saves on the encryption overhead.

@Benimautner
Copy link
Collaborator

Yes I know and it's on the roadmap, but the app is in beta and this is a quick but dirty solution to the problem.

You're welcome to submit a PR.

@denysvitali denysvitali changed the title Support User CAs Support User CAs on Android Mar 25, 2024
@denysvitali
Copy link
Contributor Author

It looks like this is the issue:
dart-lang/sdk#50435

Basically, the SDK doesn't follow the system trust store.

The "fix" is to use another HTTP client (platform-specific) that respects the system CAs:

  http.Client get httpClient {
    if (Platform.isAndroid) {
      final engine = cronet_http.CronetEngine.build(
          cacheMode: cronet_http.CacheMode.memory, cacheMaxSize: 1000000);
      return cronet_http.CronetClient.fromCronetEngine(engine);
    }
    if (Platform.isIOS || Platform.isMacOS) {
      final config =
          cupertino_http.URLSessionConfiguration.ephemeralSessionConfiguration()
            ..cache =
                cupertino_http.URLCache.withCapacity(memoryCapacity: 1000000);
      return cupertino_http.CupertinoClient.fromSessionConfiguration(config);
    }
    return io_client.IOClient();
  }

denysvitali added a commit to denysvitali/vikunja_app that referenced this issue Mar 26, 2024
@Benimautner Benimautner self-assigned this Apr 3, 2024
@Benimautner
Copy link
Collaborator

Benimautner commented Apr 3, 2024

I'm sorry for not getting back to you sooner, I've been super busy at work and other projects! Yep, that looks like a good solution. I'll try it out and let you know.
We've had a bunch of changes of the http client due to that exact reason, but I'm happy to switch once again if this fixes it.

denysvitali added a commit to denysvitali/vikunja_app that referenced this issue Apr 5, 2024
denysvitali added a commit to denysvitali/vikunja_app that referenced this issue Apr 5, 2024
feat: add policy to AndroidManifest
denysvitali added a commit to denysvitali/vikunja_app that referenced this issue Apr 6, 2024
feat: add policy to AndroidManifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants