fix(security): remove SSL bypass + hardcoded creds in face_detect, rider debug CA overrides, fix siro_service manifest
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:siro_driver/constant/api_key.dart';
|
|||||||
import 'package:siro_driver/constant/box_name.dart';
|
import 'package:siro_driver/constant/box_name.dart';
|
||||||
import 'package:siro_driver/main.dart';
|
import 'package:siro_driver/main.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:http/io_client.dart';
|
|
||||||
|
|
||||||
import '../../constant/links.dart';
|
import '../../constant/links.dart';
|
||||||
import 'encrypt_decrypt.dart';
|
import 'encrypt_decrypt.dart';
|
||||||
@@ -15,14 +14,10 @@ Future<String> faceDetector() async {
|
|||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
|
|
||||||
var headers = {
|
var headers = {
|
||||||
// 'Authorization': 'Basic ${AK.basicCompareFaces}',
|
'Authorization': 'Basic ${AK.basicCompareFaces}',
|
||||||
'Authorization': 'Basic hamza:12345678',
|
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
};
|
};
|
||||||
|
|
||||||
// var request = http.Request('POST', Uri.parse(//Todo
|
|
||||||
// 'https://face-detect-f6924392c4c7.herokuapp.com/compare_faces'));
|
|
||||||
|
|
||||||
var request = http.Request(
|
var request = http.Request(
|
||||||
'POST', Uri.parse('https://mohkh.online:5000/compare_faces'));
|
'POST', Uri.parse('https://mohkh.online:5000/compare_faces'));
|
||||||
|
|
||||||
@@ -32,39 +27,25 @@ Future<String> faceDetector() async {
|
|||||||
"url2":
|
"url2":
|
||||||
"https://api.sefer.live/sefer/card_image/face_detect-${(box.read(BoxName.driverID))}.jpg"
|
"https://api.sefer.live/sefer/card_image/face_detect-${(box.read(BoxName.driverID))}.jpg"
|
||||||
});
|
});
|
||||||
print('request.body: ${request.body}');
|
|
||||||
request.headers.addAll(headers);
|
request.headers.addAll(headers);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http.Client client = await createHttpClient();
|
http.StreamedResponse response = await request.send();
|
||||||
http.StreamedResponse response = await client.send(request);
|
|
||||||
// http.StreamedResponse response = await request.send();
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
String result = await response.stream.bytesToString();
|
String result = await response.stream.bytesToString();
|
||||||
print('result: ${result}');
|
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
print('Error: ${response.reasonPhrase}');
|
|
||||||
return 'Error: ${response.reasonPhrase}';
|
return 'Error: ${response.reasonPhrase}';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
|
||||||
return 'Error: $e';
|
return 'Error: $e';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<http.Client> createHttpClient() async {
|
|
||||||
final SecurityContext securityContext = SecurityContext();
|
|
||||||
HttpClient httpClient = HttpClient(context: securityContext);
|
|
||||||
httpClient.badCertificateCallback =
|
|
||||||
(X509Certificate cert, String host, int port) => true; // Bypass SSL
|
|
||||||
return IOClient(httpClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> faceDetector2(String url1, String url2) async {
|
Future<String> faceDetector2(String url1, String url2) async {
|
||||||
var headers = {
|
var headers = {
|
||||||
'Authorization': 'Basic hamza:12345678',
|
'Authorization': 'Basic ${AK.basicCompareFaces}',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,18 +56,10 @@ Future<String> faceDetector2(String url1, String url2) async {
|
|||||||
request.headers.addAll(headers);
|
request.headers.addAll(headers);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http.Client client = await createHttpClient(); // Use custom client
|
http.StreamedResponse response = await request.send();
|
||||||
DateTime startTime = DateTime.now();
|
|
||||||
http.StreamedResponse response = await client.send(request);
|
|
||||||
DateTime endTime = DateTime.now();
|
|
||||||
Duration duration = endTime.difference(startTime);
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print(await response.stream.bytesToString());
|
|
||||||
print(duration.inSeconds);
|
|
||||||
|
|
||||||
return await response.stream.bytesToString();
|
return await response.stream.bytesToString();
|
||||||
} else {
|
} else {
|
||||||
print(await response.stream.bytesToString());
|
|
||||||
return 'Error: ${response.reasonPhrase}';
|
return 'Error: ${response.reasonPhrase}';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -18,11 +18,4 @@
|
|||||||
</pin-set>
|
</pin-set>
|
||||||
</domain-config>
|
</domain-config>
|
||||||
|
|
||||||
<debug-overrides>
|
|
||||||
<trust-anchors>
|
|
||||||
<certificates src="system" />
|
|
||||||
<certificates src="user" />
|
|
||||||
</trust-anchors>
|
|
||||||
</debug-overrides>
|
|
||||||
|
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
@@ -64,6 +64,9 @@
|
|||||||
<application
|
<application
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:label="service"
|
android:label="service"
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:fullBackupContent="false"
|
||||||
|
android:usesCleartextTraffic="false"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:icon="@mipmap/launcher_icon">
|
android:icon="@mipmap/launcher_icon">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user