Skip to content

Commit 95cfbd8

Browse files
committed
wip [skip ci]
1 parent e43f44f commit 95cfbd8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

cw_core/lib/node.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,13 @@ class Node extends HiveObject with Keyable {
215215
final body = {'jsonrpc': '2.0', 'id': '0', 'method': methodName};
216216

217217
try {
218-
final authenticatingClient = HttpClient();
219-
authenticatingClient.badCertificateCallback =
220-
((X509Certificate cert, String host, int port) => true);
221-
222218
final jsonBody = json.encode(body);
223219

224220
final response = await ProxyWrapper().post(
225221
clearnetUri: rpcUri,
226222
headers: {'Content-Type': 'application/json'},
227223
body: jsonBody,
224+
allowMitmMoneroBypassSSLCheck: true,
228225
);
229226
// Check if we received a 401 Unauthorized response
230227
if (response.statusCode == 401) {

cw_core/lib/utils/proxy_wrapper.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dart:convert';
12
import 'dart:io';
23
import 'package:socks5_proxy/socks_client.dart';
34
import 'package:tor/tor.dart';
@@ -75,7 +76,7 @@ class ProxyWrapper {
7576
});
7677
}
7778
if (body != null) {
78-
request.write(body);
79+
request.add(utf8.encode(body));
7980
}
8081
await request.flush();
8182
return await request.close();
@@ -94,7 +95,7 @@ class ProxyWrapper {
9495
});
9596
}
9697
if (body != null) {
97-
request.write(body);
98+
request.add(utf8.encode(body));
9899
}
99100
await request.flush();
100101
return await request.close();
@@ -170,15 +171,26 @@ class ProxyWrapper {
170171
Uri? clearnetUri,
171172
Uri? onionUri,
172173
String? body,
174+
bool allowMitmMoneroBypassSSLCheck = false,
173175
}) async {
174176
HttpClient? torClient;
177+
HttpClient clearnetClient = HttpClient();
178+
179+
if (allowMitmMoneroBypassSSLCheck) {
180+
clearnetClient.badCertificateCallback =
181+
((X509Certificate cert, String host, int port) => true);
182+
}
183+
175184
bool torEnabled = CakeTor.instance.started;
176185

177186
if (torEnabled) {
178187
try {
179188
torClient = await getProxyHttpClient(portOverride: portOverride);
180189
} catch (_) {}
181-
190+
if (allowMitmMoneroBypassSSLCheck) {
191+
torClient!.badCertificateCallback =
192+
((X509Certificate cert, String host, int port) => true);
193+
}
182194
if (onionUri != null) {
183195
try {
184196
return await makePost(
@@ -207,7 +219,7 @@ class ProxyWrapper {
207219
return HttpOverrides.runZoned(
208220
() async {
209221
return await makePost(
210-
client: HttpClient(),
222+
client: clearnetClient,
211223
uri: clearnetUri,
212224
headers: headers,
213225
body: body,

0 commit comments

Comments
 (0)