I want to use a php API to connect to my MySql database but I get the following error all the time:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
I know I need a certificate but I have no clue how to create one, because I am the host which is why I need to create it my self.
The php code is the following from this github : https://github.com/VishnuSivadasVS/LogIn-SignUp
<?php
require "DataBase.php";
$db = new DataBase();
if (isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password'])) {
if ($db->dbConnect()) {
if ($db->signUp("users", $_POST['fullname'], $_POST['email'], $_POST['username'], $_POST['password'])) {
echo "Sign Up Success";
} else echo "Sign up Failed";
} else echo "Error: Database connection";
} else echo "All fields are required";
?>
And this is how I try to connect in my Java/Android Code:
public void run() {
//Starting Write and Read data with URL
//Creating array for parameters
String[] field = new String[4];
field[0] = "fullname";
field[1] = "username";
field[2] = "password";
field[3] = "email";
//Creating array for data
String[] data = new String[4];
data[0] = fullnametext;
data[1] = usernametext;
data[2] = passwordtext;
data[3] = emailtext;
PutData putData = new PutData("https://127.0.0.1/LoginRegister/signup.php", "POST", field, data);
if (putData.startPut()) {
if (putData.onComplete()) {
String result = putData.getResult();
progressBar.setVisibility(View.GONE);
if(result.equals("Sign Up Success")){
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();
Log.i("Result", result);
Intent intent = new Intent(getApplicationContext(), LogIn.class);
startActivity(intent);
finish();
}
It would really help me if anybody could tell me how to create the certificate I need and where to put it in my android code.
Thanks for any help :)
I already searched for information, but I only ran into more questions. Like do I need a certificate for my database or the php Code?