From 02688a2a036e32626ac18e7fd8a93166419dcde9 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Fri, 25 Jul 2025 00:56:00 +0530 Subject: [PATCH] fix: override SSL options inside isolates (#20142) Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- mobile/lib/utils/http_ssl_options.dart | 8 ++++---- mobile/lib/utils/isolate.dart | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mobile/lib/utils/http_ssl_options.dart b/mobile/lib/utils/http_ssl_options.dart index 04c01d36d9..24e51f1b30 100644 --- a/mobile/lib/utils/http_ssl_options.dart +++ b/mobile/lib/utils/http_ssl_options.dart @@ -10,18 +10,18 @@ import 'package:logging/logging.dart'; class HttpSSLOptions { static const MethodChannel _channel = MethodChannel('immich/httpSSLOptions'); - static void apply() { + static void apply({bool applyNative = true}) { AppSettingsEnum setting = AppSettingsEnum.allowSelfSignedSSLCert; bool allowSelfSignedSSLCert = Store.get(setting.storeKey as StoreKey, setting.defaultValue); - _apply(allowSelfSignedSSLCert); + _apply(allowSelfSignedSSLCert, applyNative: applyNative); } static void applyFromSettings(bool newValue) { _apply(newValue); } - static void _apply(bool allowSelfSignedSSLCert) { + static void _apply(bool allowSelfSignedSSLCert, {bool applyNative = true}) { String? serverHost; if (allowSelfSignedSSLCert && Store.tryGet(StoreKey.currentUser) != null) { serverHost = Uri.parse(Store.tryGet(StoreKey.serverEndpoint) ?? "").host; @@ -32,7 +32,7 @@ class HttpSSLOptions { HttpOverrides.global = HttpSSLCertOverride(allowSelfSignedSSLCert, serverHost, clientCert); - if (Platform.isAndroid) { + if (applyNative && Platform.isAndroid) { _channel.invokeMethod("apply", [ allowSelfSignedSSLCert, serverHost, diff --git a/mobile/lib/utils/isolate.dart b/mobile/lib/utils/isolate.dart index 3c2aeed756..a506aa4858 100644 --- a/mobile/lib/utils/isolate.dart +++ b/mobile/lib/utils/isolate.dart @@ -9,6 +9,7 @@ import 'package:immich_mobile/providers/db.provider.dart'; import 'package:immich_mobile/providers/infrastructure/cancel.provider.dart'; import 'package:immich_mobile/providers/infrastructure/db.provider.dart'; import 'package:immich_mobile/utils/bootstrap.dart'; +import 'package:immich_mobile/utils/http_ssl_options.dart'; import 'package:logging/logging.dart'; import 'package:worker_manager/worker_manager.dart'; @@ -48,6 +49,7 @@ Cancelable runInIsolateGentle({ Logger log = Logger("IsolateLogger"); try { + HttpSSLOptions.apply(applyNative: false); return await computation(ref); } on CanceledError { log.warning(