fix: override SSL options inside isolates (#20142)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2025-07-25 00:56:00 +05:30 committed by GitHub
parent 3b9bfceef0
commit 02688a2a03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -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<bool>, 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,