Now wait until self signed certs are loaded during init

This commit is contained in:
Ming Ming 2024-06-19 16:17:24 +08:00
parent e573837b7b
commit c576b917e1
2 changed files with 12 additions and 9 deletions

View file

@ -69,7 +69,7 @@ Future<void> init(InitIsolateType isolateType) async {
await _initAccountPrefs();
_initEquatable();
if (features.isSupportSelfSignedCert) {
_initSelfSignedCertManager();
await _initSelfSignedCertManager();
}
await _initDiContainer(isolateType);
_initVisibilityDetector();
@ -134,8 +134,13 @@ void _initEquatable() {
EquatableConfig.stringify = false;
}
void _initSelfSignedCertManager() {
SelfSignedCertManager().init();
Future<void> _initSelfSignedCertManager() async {
try {
return SelfSignedCertManager().init();
} catch (e, stackTrace) {
_log.shout("[_initSelfSignedCertManager] Failed to load self signed certs",
e, stackTrace);
}
}
Future<void> _initDiContainer(InitIsolateType isolateType) async {

View file

@ -16,14 +16,12 @@ part 'self_signed_cert_manager.g.dart';
class SelfSignedCertManager {
factory SelfSignedCertManager() => _inst;
SelfSignedCertManager._() {
_readAllCerts().then((infos) {
_whitelist = infos;
});
}
SelfSignedCertManager._();
void init() {
Future<void> init() async {
HttpOverrides.global = _CustomHttpOverrides();
final infos = await _readAllCerts();
_whitelist = infos;
}
/// Verify [cert] and return if it's registered in the whitelist for [host]