I have an application that has a piece of code that is responsible for authorization. I sent the encrypted data to the server, the data on the server will be checked, if everything is fine with the data, then I return the code 200 and additional data. I tested this code on the server without protection (http). But now when I started debugging this application with a server that has a certificate (https) I had a problem. Maybe someone knows how to solve this problem? Here is the problem code:
E/flutter (23247): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error: E/flutter (23247): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354))
Here is my code:
signIn(String login, pass) async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var AESLogin = login;
var AESpass = pass;
//generate a 16-byte random key
var key = '33CC2E0DD531B761316FE1231231211';
print(key);
//encrypt
var encryptLogin = await FlutterAesEcbPkcs5.encryptString(AESLogin, key);
var encryptPass = await FlutterAesEcbPkcs5.encryptString(AESpass, key);
var jsonResponse = null;
var response = await http.post(
global.urlVar + "/auth_user", body: json.encode(
{
"login": encryptLogin,
"pass": encryptPass
}),
);
if (response.statusCode == 200) {
jsonResponse = json.decode(response.body);
print('Response body: ${response.body}');
if (jsonResponse['message'] ==
'200') { //if( jsonResponse['message'] == '200') {
setState(() {
_isLoading = false;
});
global.nameUser = jsonResponse['name'];
global.dataArea = jsonResponse['data_area'];
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyApp()),
);
}
else {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Error_Auth()),
);
}
}
else {
setState(() {
_isLoading = false;
});
print(response.body);
}
}