mirror of
https://github.com/immich-app/immich.git
synced 2025-08-11 09:16:31 -04:00
* chore: bump dart sdk to 3.8 * chore: make build * make pigeon * chore: format files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
43 lines
1.6 KiB
Dart
43 lines
1.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
|
import 'package:immich_mobile/utils/http_ssl_cert_override.dart';
|
|
import 'package:logging/logging.dart';
|
|
|
|
class HttpSSLOptions {
|
|
static const MethodChannel _channel = MethodChannel('immich/httpSSLOptions');
|
|
|
|
static void apply({bool applyNative = true}) {
|
|
AppSettingsEnum setting = AppSettingsEnum.allowSelfSignedSSLCert;
|
|
bool allowSelfSignedSSLCert = Store.get(setting.storeKey as StoreKey<bool>, setting.defaultValue);
|
|
_apply(allowSelfSignedSSLCert, applyNative: applyNative);
|
|
}
|
|
|
|
static void applyFromSettings(bool newValue) {
|
|
_apply(newValue);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
SSLClientCertStoreVal? clientCert = SSLClientCertStoreVal.load();
|
|
|
|
HttpOverrides.global = HttpSSLCertOverride(allowSelfSignedSSLCert, serverHost, clientCert);
|
|
|
|
if (applyNative && Platform.isAndroid) {
|
|
_channel
|
|
.invokeMethod("apply", [allowSelfSignedSSLCert, serverHost, clientCert?.data, clientCert?.password])
|
|
.onError<PlatformException>((e, _) {
|
|
final log = Logger("HttpSSLOptions");
|
|
log.severe('Failed to set SSL options', e.message);
|
|
});
|
|
}
|
|
}
|
|
}
|