Initial commit
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2026-09-11 15:59:56 -03:00
commit 0037b0b9cf
651 changed files with 199705 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:convert';
import 'dart:io';
import 'package:tatchat/config/isrg_x1.dart';
import 'package:tatchat/config/isrg_x2.dart';
import 'package:tatchat/utils/platform_infos.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:http/retry.dart' as retry;
/// Custom HTTP client that adds the ISRG Root certificates used by Let's
/// Encrypt. Older Android versions may not include these roots in their
/// trust store, so we ship them ourselves to ensure TLS connections to
/// Let's Encrypt–signed servers continue to work.
class CustomHttpClient {
static HttpClient customHttpClient() {
final context = SecurityContext.defaultContext;
try {
context.setTrustedCertificatesBytes(utf8.encode(ISRG_X1));
context.setTrustedCertificatesBytes(utf8.encode(ISRG_X2));
} on TlsException catch (e) {
if (e.osError != null &&
e.osError!.message.contains('CERT_ALREADY_IN_HASH_TABLE')) {
} else {
rethrow;
}
}
return HttpClient(context: context);
}
static http.Client createHTTPClient() => retry.RetryClient(
PlatformInfos.isAndroid ? IOClient(customHttpClient()) : http.Client(),
);
}