Facts
I have Apache/2.4.27 (Win64) PHP/7.2.0beta3 on Win 10 laptop. I want to implement cURL. This is my code
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.youtube.com');
curl_exec($curl);
if (curl_errno ( $curl )) {
echo curl_error ( $curl );
curl_close ( $curl );
}
that generates the error SSL certificate problem: unable to get local issuer certificate
. So I downloaded certificates from https://curl.haxx.se/ca/cacert.pem. Took the cacert.pem file, put it in the PHP folder and edited the php.ini
file like this
curl.cainfo = C:php/ext/cacert.pem
.
Problem
Now I get this error error setting certificate verify locations: CAfile: C:php/ext/cacert.pem CApath: none
. I googled and the only solution I found is that I have to download the .crt
file from the site I want to cURL and include it in my cURL like curl_setopt($curl, CURLOPT_CAINFO, "C:/wamp64/www/GIAG2.crt");
.
Problem 1.1 :
I dont know how to download the .crt
file so I can include it in my code, like the above example.
Problem 1.2 : That is not a "universal" solution, I want to set my certificates in such way that I dont have to download different certificates for different site.
Thank you