merge
This commit is contained in:
parent
80ac39b624
commit
f327927fdd
|
|
@ -1,6 +1,8 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:extera_next/config/app_config.dart';
|
||||
import 'package:extera_next/utils/platform_infos.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/io_client.dart';
|
||||
|
||||
|
|
@ -12,20 +14,30 @@ class CustomHttpClient {
|
|||
|
||||
final context = SecurityContext.defaultContext;
|
||||
|
||||
try {
|
||||
if (cert != null) {
|
||||
final bytes = utf8.encode(cert);
|
||||
context.setTrustedCertificatesBytes(bytes);
|
||||
}
|
||||
} on TlsException catch (e) {
|
||||
if (e.osError != null &&
|
||||
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
||||
} else {
|
||||
rethrow;
|
||||
if (PlatformInfos.isAndroid) {
|
||||
try {
|
||||
if (cert != null) {
|
||||
final bytes = utf8.encode(cert);
|
||||
context.setTrustedCertificatesBytes(bytes);
|
||||
}
|
||||
} on TlsException catch (e) {
|
||||
if (e.osError != null &&
|
||||
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HttpClient(context: context);
|
||||
final client = HttpClient(context: context);
|
||||
|
||||
if (AppConfig.httpProxy != null) {
|
||||
client.findProxy = (uri) {
|
||||
return "PROXY ${AppConfig.httpProxy};";
|
||||
};
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
|
||||
|
|
|
|||
Loading…
Reference in New Issue