PHP Curl error: SSL certificate problem: self signed certificate in certificate chain

Viewed 93

I'm trying to send a curl request to an API and I'm getting the error mentioned in the title. I've seen other posts about this error and I've downloaded the CA certificates from https://curl.se/docs/caextract.html, but I'm still having trouble getting around this error.

My code currently looks like this:

    $request = curl_init($url . $endpoint);
    curl_setopt($request, CURLOPT_URL, $url . $endpoint);
    curl_setopt($request, CURLOPT_HTTPHEADER, $header);
    curl_setopt($request, CURLOPT_USERPWD, $username . ":" . $password);
    curl_setopt ($ch, CURLOPT_CAINFO, [path to CA certificate file, locally stored]);

    $response = curl_exec($request);

Can anyone advise me on what I'm doing wrong here?

Edit: To include it in the question body as requested, here is the error message that I'm seeing in the curl response:

SSL certificate problem: self signed certificate in certificate chain

Edit2: I should also mention that the machine I'm running this on is a Windows machine

1 Answers
$request = curl_init($url . $endpoint);
curl_setopt($request, CURLOPT_URL, $url . $endpoint);
curl_setopt($request, CURLOPT_HTTPHEADER, $header);
curl_setopt($request, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);

$response = curl_exec($request);
Related