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

feat(mobile): trust user-added CAs #14403

Closed
wants to merge 1 commit into from

Conversation

vfreex
Copy link

@vfreex vfreex commented Nov 29, 2024

This PR allows the Android app to trust user-added CAs without skipping SSL certificate verification.

It is pretty common that a self-hosted Immich server uses an SSL certificate issued by a self-signed CA, such as a company's internal CA.

On Android systems, users can install a custom CA certificate by going to system Settings -> Security & privacy -> More Security and privacy -> Encryption & credentials -> Install a certificate. However, starting with Android N, an app doesn't trust user-added CAs by default unless it explicitly opts in. See
https://developer.android.com/privacy-and-security/security-config for more information.

iOS doesn't have this issue because it always trust user-added CAs. Even Chrome on Android trusts user-added CAs (https://github.com/chromium/chromium/blob/f65f60551faa7e21c176c951cf874ce98278fd0b/chrome/android/java/res_base/xml/network_security_config.xml#L8) so it shouldn't a security concern.

Copy link
Contributor

Label error. Requires exactly 1 of: changelog:.*. Found:

This PR allows the Android app to trust user-added CAs without skipping SSL
certificate verification.

It is pretty common that a self-hosted Immich server uses an SSL
certificate issued by a self-signed CA, such as a company's
internal CA.

On Android systems, users can install a custom CA certificate
by going to system Settings -> Security & privacy -> More Security and
privacy -> Encryption & credentials -> Install a certificate.
However, starting with Android N, an app doesn't trust user-added CAs by default
unless it explicitly opts in. See
https://developer.android.com/privacy-and-security/security-config for
more information.

iOS doesn't have this issue because it always trust user-added CAs.
Even Chrome on Android trusts user-added CAs (https://github.com/chromium/chromium/blob/f65f60551faa7e21c176c951cf874ce98278fd0b/chrome/android/java/res_base/xml/network_security_config.xml#L8) so it shouldn't
a security concern.
@vfreex vfreex force-pushed the trust-user-added-cas branch from 35e3059 to 8df62b6 Compare November 29, 2024 13:30
@vfreex vfreex changed the title Android app: Trust user-added CAs feat(mobile): trust user-added CAs Nov 29, 2024
@alextran1502
Copy link
Contributor

Hello, how has this change been tested? Can you verify that it works with video?

@bo0tzz
Copy link
Member

bo0tzz commented Nov 29, 2024

Our understanding has been that Flutter has its own CA store and there's no way to have it use the system store. If that's right, this change shouldn't work at all.

@vfreex
Copy link
Author

vfreex commented Nov 29, 2024

Our understanding has been that Flutter has its own CA store and there's no way to have it use the system store. If that's right, this change shouldn't work at all.

You are correct. I solved this issue in another project but haven’t tested this with Immich. I searched for this issue and found it might be possible to use platform native API for https calls with Flutter. I will do more investigation.

@vfreex
Copy link
Author

vfreex commented Nov 30, 2024

I am able to verify this after changing the http engine from dart.io HttpClient to cronet_http as described at https://pub.dev/packages/http. But that requires more testing to ensure nothing will be broken.

@bo0tzz
Copy link
Member

bo0tzz commented Nov 30, 2024

A previous attempt at cronet was made in #5869. cc @shenlong-tanwen

@shenlong-tanwen
Copy link
Member

A previous attempt at cronet was made in #5869. cc @shenlong-tanwen

Yes using cronet/cupertino http should fix the issue. I've recently saw few other flutter projects replacing their http clients with the cronet implementation.

@alextran1502
Copy link
Contributor

Hey @vfreex, we need more metrics to justify this use case. Hence, I am closing this PR. We'll consider adding if we have more requests about this feature. Thank you for the PR.

@S-Bryce
Copy link

S-Bryce commented Dec 12, 2024

Hey @vfreex, we need more metrics to justify this use case. Hence, I am closing this PR. We'll consider adding if we have more requests about this feature. Thank you for the PR.

#5657 (comment)

It's disheartening to see this feature's PR being closed. From my understanding, last year, a PR related to trusting user-added CAs would have been welcomed, but now that one exists, it's been closed due to lacking requests. Since you mentioned that the feature needs more requests to justify its implementation, what would be the best way to make such a request?

@hzxa21
Copy link

hzxa21 commented Dec 16, 2024

Hey @vfreex, we need more metrics to justify this use case. Hence, I am closing this PR. We'll consider adding if we have more requests about this feature. Thank you for the PR.

#5657 (comment)

It's disheartening to see this feature's PR being closed. From my understanding, last year, a PR related to trusting user-added CAs would have been welcomed, but now that one exists, it's been closed due to lacking requests. Since you mentioned that the feature needs more requests to justify its implementation, what would be the best way to make such a request?

+1 for the request, which has been bothered me for a while.

@dkay0670
Copy link

+1

@simon-n
Copy link

simon-n commented Dec 28, 2024

I'm also looking for a way to get my local PKI working for Immich and would really appreciate further effort on this PR 👍

@aechmtwash
Copy link

+1

@alekstnr
Copy link

+1

Wondering if this will fix the issue I am currently having with the android app connecting to our server, which is behind mTLS signed by our own CA.
When we import the p12 into the app, and enter the password, it just fails and says invalid.
This same p12 works correctly for visiting the webapp version of immich and our other services.
I have tried enabling the "allow self-signed certs" option, but still does not work.

@immich-app immich-app locked and limited conversation to collaborators Dec 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants