From 6a59938622c29419806df5ec8146253809e8f561 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Jan 2025 16:57:13 +0100 Subject: [PATCH 1/2] Make the android app able to send POST request to the server --- .../verification_service.dart | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/Mobile_App/lib/services/verification_service/verification_service.dart b/Mobile_App/lib/services/verification_service/verification_service.dart index e8b1d70..9e6bb3e 100644 --- a/Mobile_App/lib/services/verification_service/verification_service.dart +++ b/Mobile_App/lib/services/verification_service/verification_service.dart @@ -42,7 +42,7 @@ class CheckServerFingerprints { class VerificationService { static Future getFingerprints(Uri url, { - bool? withResponse, + bool? withResponse, Map? postArguments }) async { try { if (kIsWeb == true) { @@ -63,12 +63,25 @@ class VerificationService { dynamic response; String? ip; - HttpClientRequest httpsConnectionRequest = await (withResponse == true - ? client.getUrl(url) - : client.openUrl( - "HEAD", - url, - )); + HttpClientRequest httpsConnectionRequest; + + if (withResponse == true) + { + if (postArguments != null) { + httpsConnectionRequest = await client.postUrl(url); + httpsConnectionRequest.headers.set(HttpHeaders.contentTypeHeader, "application/json; charset=UTF-8"); + httpsConnectionRequest.write(jsonEncode(postArguments)); + } + else + { + httpsConnectionRequest = await client.getUrl(url); + } + + } + else + { + httpsConnectionRequest = await client.openUrl("HEAD", url); + } HttpClientResponse httpsConnection = await httpsConnectionRequest.done.timeout( @@ -87,6 +100,7 @@ class VerificationService { } response = json.decode(contents.toString()); } + List? cert = httpsConnection.certificate?.der.toList(); Digest? mdSHA256 = cert != null ? sha256.convert(cert) : null; await InternetAddress.lookup(url.host).then( @@ -162,14 +176,14 @@ class VerificationService { scheme: "https", host: apiBaseUrl, path: "api.php", - queryParameters: { + ), + withResponse: true, + postArguments: { "host": host, "port": port, "ip": ip, - "sign": sign + "sign": true }, - ), - withResponse: true, ); return CheckServerFingerprints( @@ -186,12 +200,12 @@ class VerificationService { scheme: "https", host: apiBaseUrl, path: "api.php", - queryParameters: { - "info" : "", - "sign": "" - }, ), withResponse: true, + postArguments: { + "info" : "", + "sign": true + } ); return CheckServerFingerprints( apiInfo: requestFingerprints.response, From 06413a5587ee68bad25a3ad8e6f803684c1a23d4 Mon Sep 17 00:00:00 2001 From: CheckMyHTTPS Date: Thu, 23 Jan 2025 10:47:33 +0100 Subject: [PATCH 2/2] Update verification_service.dart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need to allow the android application to continue making “get” requests. --- .../verification_service/verification_service.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Mobile_App/lib/services/verification_service/verification_service.dart b/Mobile_App/lib/services/verification_service/verification_service.dart index 9e6bb3e..bfae273 100644 --- a/Mobile_App/lib/services/verification_service/verification_service.dart +++ b/Mobile_App/lib/services/verification_service/verification_service.dart @@ -67,16 +67,9 @@ class VerificationService { if (withResponse == true) { - if (postArguments != null) { - httpsConnectionRequest = await client.postUrl(url); - httpsConnectionRequest.headers.set(HttpHeaders.contentTypeHeader, "application/json; charset=UTF-8"); - httpsConnectionRequest.write(jsonEncode(postArguments)); - } - else - { - httpsConnectionRequest = await client.getUrl(url); - } - + httpsConnectionRequest = await client.postUrl(url); + httpsConnectionRequest.headers.set(HttpHeaders.contentTypeHeader, "application/json; charset=UTF-8"); + httpsConnectionRequest.write(jsonEncode(postArguments)); } else {