[Feature]: Support mTLS / Client TLS Certificates in Mobile App #667

Closed
opened 2026-02-04 21:47:10 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @JabobKrauskopf on GitHub (Feb 7, 2023).

Feature detail

Background
I would like to access my instance of Immich from outside my network. However, the only option I have without exposing it to the internet is to use a VPN, which I would like to avoid. Configuring my reverse-proxy to require mutual TLS / client certificates could reduce the risk of exposing Immich by adding an extra layer of protection.

Proposal
Ideally, the Immich app could access the iOS / Android keychain and use a client certificate that is installed system-wide for any requests to the Immich server.

Problem
After taking a stab at implementing this feature on Android by accessing the native keychain, I ran into the following issue. The Dart HTTP Client supports client certificates by configuring a SecurityContext object with useCertificateChainBytes() and usePrivateKeyBytes(). However, these methods require the actual contents of the private key, but the Android KeyChain.getPrivateKey() API only returns an opaque key. The built-in Dart HTTP client does not seem to support this (see https://github.com/dart-lang/sdk/issues/50669#issuecomment-1350624999).

Apps like HomeAssistant support client certificates because the OkHttp library seems to use native Android APIs (see https://github.com/home-assistant/android/pull/2526).

Solutions
One solution would be to have some kind of advanced options section on the login screen where a user uploads a client certificate. However, this would be less than ideal since we would bypass the system keystore which already provides this functionality.

Another option that might be worth exploring is a custom header that contains a secret token which is sent with every request. Maybe something like this: https://github.com/immich-app/immich/issues/1305

I would appreciate any insights/help on how one might approach implementing mutual TLS.

Platform

Mobile App

Originally created by @JabobKrauskopf on GitHub (Feb 7, 2023). ### Feature detail **Background** I would like to access my instance of Immich from outside my network. However, the only option I have without exposing it to the internet is to use a VPN, which I would like to avoid. Configuring my reverse-proxy to require [mutual TLS / client certificates ](https://www.cloudflare.com/en-gb/learning/access-management/what-is-mutual-tls/) could reduce the risk of exposing Immich by adding an extra layer of protection. **Proposal** Ideally, the Immich app could access the iOS / Android keychain and use a client certificate that is installed system-wide for any requests to the Immich server. **Problem** After taking a stab at implementing this feature on Android by accessing the native keychain, I ran into the following issue. The Dart HTTP Client supports client certificates by configuring a `SecurityContext` object with `useCertificateChainBytes()` and `usePrivateKeyBytes()`. However, these methods require the actual contents of the private key, but the Android `KeyChain.getPrivateKey()` API only returns an opaque key. The built-in Dart HTTP client does not seem to support this (see https://github.com/dart-lang/sdk/issues/50669#issuecomment-1350624999). Apps like HomeAssistant support client certificates because the OkHttp library seems to use native Android APIs (see https://github.com/home-assistant/android/pull/2526). **Solutions** One solution would be to have some kind of advanced options section on the login screen where a user uploads a client certificate. However, this would be less than ideal since we would bypass the system keystore which already provides this functionality. Another option that might be worth exploring is a custom header that contains a secret token which is sent with every request. Maybe something like this: https://github.com/immich-app/immich/issues/1305 I would appreciate any insights/help on how one might approach implementing mutual TLS. ### Platform Mobile App
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#667