mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-06 17:15:50 -06:00
32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:paperless_mobile/di_initializer.config.dart';
|
|
import 'package:paperless_mobile/di_modules.dart';
|
|
import 'package:paperless_mobile/features/login/model/client_certificate.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:injectable/injectable.dart';
|
|
|
|
final getIt = GetIt.instance..allowReassignment;
|
|
|
|
@InjectableInit(
|
|
initializerName: r'$initGetIt', // default
|
|
preferRelativeImports: true, // default
|
|
asExtension: false, // default
|
|
)
|
|
void configureDependencies() => $initGetIt(getIt);
|
|
|
|
///
|
|
/// Registers new security context, which will be used by the HttpClient, see [RegisterModule].
|
|
///
|
|
void registerSecurityContext(ClientCertificate? cert) {
|
|
var context = SecurityContext();
|
|
if (cert != null) {
|
|
context = context
|
|
..usePrivateKeyBytes(cert.bytes, password: cert.passphrase)
|
|
..useCertificateChainBytes(cert.bytes, password: cert.passphrase)
|
|
..setTrustedCertificatesBytes(cert.bytes, password: cert.passphrase);
|
|
}
|
|
getIt.unregister<SecurityContext>();
|
|
getIt.registerSingleton<SecurityContext>(context);
|
|
}
|