mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 11:45:10 +00:00
fix: pass isrg cert to http client
This commit is contained in:
parent
0047fc8fa7
commit
9f1df557df
5 changed files with 95 additions and 28 deletions
32
lib/config/isrg_x1.dart
Normal file
32
lib/config/isrg_x1.dart
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// ignore: constant_identifier_names
|
||||||
|
const String ISRG_X1 = """-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
||||||
|
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||||
|
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
||||||
|
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
||||||
|
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
||||||
|
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
||||||
|
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
||||||
|
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
||||||
|
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
|
||||||
|
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
|
||||||
|
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
|
||||||
|
B5iPNgiV5+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ChP4kqKOJ2qxq
|
||||||
|
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
||||||
|
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
||||||
|
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
||||||
|
-----END CERTIFICATE-----""";
|
|
@ -7,6 +7,7 @@ import 'package:matrix/encryption/utils/key_verification.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/utils/custom_http_client.dart';
|
||||||
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
|
@ -82,8 +83,11 @@ abstract class ClientManager {
|
||||||
await Store().setItem(clientNamespace, jsonEncode(clientNamesList));
|
await Store().setItem(clientNamespace, jsonEncode(clientNamesList));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Client createClient(String clientName) => Client(
|
static Client createClient(String clientName) {
|
||||||
|
final _client = CustomHttpClient.createHTTPClient();
|
||||||
|
return Client(
|
||||||
clientName,
|
clientName,
|
||||||
|
httpClient: _client,
|
||||||
verificationMethods: {
|
verificationMethods: {
|
||||||
KeyVerificationMethod.numbers,
|
KeyVerificationMethod.numbers,
|
||||||
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
||||||
|
@ -108,3 +112,4 @@ abstract class ClientManager {
|
||||||
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
30
lib/utils/custom_http_client.dart
Normal file
30
lib/utils/custom_http_client.dart
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:http/io_client.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/config/isrg_x1.dart';
|
||||||
|
|
||||||
|
class CustomHttpClient {
|
||||||
|
static HttpClient customHttpClient(String? cert) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpClient(context: context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
|
||||||
|
}
|
|
@ -519,7 +519,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
onLoginStateChanged.values.map((s) => s.cancel());
|
onLoginStateChanged.values.map((s) => s.cancel());
|
||||||
onOwnPresence.values.map((s) => s.cancel());
|
onOwnPresence.values.map((s) => s.cancel());
|
||||||
onNotification.values.map((s) => s.cancel());
|
onNotification.values.map((s) => s.cancel());
|
||||||
|
client.httpClient.close();
|
||||||
onFocusSub?.cancel();
|
onFocusSub?.cancel();
|
||||||
onBlurSub?.cancel();
|
onBlurSub?.cancel();
|
||||||
_backgroundPush?.onLogin?.cancel();
|
_backgroundPush?.onLogin?.cancel();
|
||||||
|
|
|
@ -939,7 +939,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: null-safety
|
ref: null-safety
|
||||||
resolved-ref: "a3d4020911860ff091d90638ab708604b71d2c5a"
|
resolved-ref: a3d4020911860ff091d90638ab708604b71d2c5a
|
||||||
url: "https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git"
|
url: "https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.4"
|
version: "0.1.4"
|
||||||
|
@ -1947,7 +1947,7 @@ packages:
|
||||||
name: visibility_detector
|
name: visibility_detector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.2"
|
version: "0.3.3"
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in a new issue