mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
fix: override SSL options inside isolates (#20142)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
3b9bfceef0
commit
02688a2a03
@ -10,18 +10,18 @@ import 'package:logging/logging.dart';
|
|||||||
class HttpSSLOptions {
|
class HttpSSLOptions {
|
||||||
static const MethodChannel _channel = MethodChannel('immich/httpSSLOptions');
|
static const MethodChannel _channel = MethodChannel('immich/httpSSLOptions');
|
||||||
|
|
||||||
static void apply() {
|
static void apply({bool applyNative = true}) {
|
||||||
AppSettingsEnum setting = AppSettingsEnum.allowSelfSignedSSLCert;
|
AppSettingsEnum setting = AppSettingsEnum.allowSelfSignedSSLCert;
|
||||||
bool allowSelfSignedSSLCert =
|
bool allowSelfSignedSSLCert =
|
||||||
Store.get(setting.storeKey as StoreKey<bool>, setting.defaultValue);
|
Store.get(setting.storeKey as StoreKey<bool>, setting.defaultValue);
|
||||||
_apply(allowSelfSignedSSLCert);
|
_apply(allowSelfSignedSSLCert, applyNative: applyNative);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void applyFromSettings(bool newValue) {
|
static void applyFromSettings(bool newValue) {
|
||||||
_apply(newValue);
|
_apply(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _apply(bool allowSelfSignedSSLCert) {
|
static void _apply(bool allowSelfSignedSSLCert, {bool applyNative = true}) {
|
||||||
String? serverHost;
|
String? serverHost;
|
||||||
if (allowSelfSignedSSLCert && Store.tryGet(StoreKey.currentUser) != null) {
|
if (allowSelfSignedSSLCert && Store.tryGet(StoreKey.currentUser) != null) {
|
||||||
serverHost = Uri.parse(Store.tryGet(StoreKey.serverEndpoint) ?? "").host;
|
serverHost = Uri.parse(Store.tryGet(StoreKey.serverEndpoint) ?? "").host;
|
||||||
@ -32,7 +32,7 @@ class HttpSSLOptions {
|
|||||||
HttpOverrides.global =
|
HttpOverrides.global =
|
||||||
HttpSSLCertOverride(allowSelfSignedSSLCert, serverHost, clientCert);
|
HttpSSLCertOverride(allowSelfSignedSSLCert, serverHost, clientCert);
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (applyNative && Platform.isAndroid) {
|
||||||
_channel.invokeMethod("apply", [
|
_channel.invokeMethod("apply", [
|
||||||
allowSelfSignedSSLCert,
|
allowSelfSignedSSLCert,
|
||||||
serverHost,
|
serverHost,
|
||||||
|
@ -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/cancel.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||||
import 'package:immich_mobile/utils/bootstrap.dart';
|
import 'package:immich_mobile/utils/bootstrap.dart';
|
||||||
|
import 'package:immich_mobile/utils/http_ssl_options.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:worker_manager/worker_manager.dart';
|
import 'package:worker_manager/worker_manager.dart';
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ Cancelable<T?> runInIsolateGentle<T>({
|
|||||||
Logger log = Logger("IsolateLogger");
|
Logger log = Logger("IsolateLogger");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
HttpSSLOptions.apply(applyNative: false);
|
||||||
return await computation(ref);
|
return await computation(ref);
|
||||||
} on CanceledError {
|
} on CanceledError {
|
||||||
log.warning(
|
log.warning(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user