Connecting PHP with remote mysql with ssl works via command, but not in browser

I want to connect to a remote (AWS) mysql server using ssl in PHP .. p>

My script works when I execute it through the command line, but not when I call it from the browser.

$con=mysqli_init();
mysqli_ssl_set($con,NULL,NULL,"path/to/cacert.pem",NULL,NULL);
$link = mysqli_real_connect($con, "host", "username", "password");

I am using php7 / Apache / CentOs. I tried to change the ownership and permissions of the CA file and noticed that this required read permission to be executed on the console. But in the browser, even if I give full permission to everyone (chmod 777), it still doesn't work.

The error I get is: Warning: Could not load cafile stream. When I check the existence of a file, it returns true, but when I check is_readible, then there is also an error.

Can anyone help? Thanks!

+6
source share
1 answer

So, I realized that there is (is) something wrong with readability and, possibly, permissions. I could narrow the problem down to the point that the certificate file exists but cannot be read. I moved it to my server with the file file via ftp.

, .pem . , , , xmod xxx chown.

( AWS MYSQL) :

+1

All Articles