Curl reports SSL certificate problem despite having installed Curl's cacert.pem

Viewed 16

I downloaded cacert.pem and saved it under PHP extras/ssl folder. In phpinfo() I can see that the cert is pointed at, by curl.cainfo.

I test with the following script:

<?Php
$curl = curl_init() or die("init failed");
curl_setopt($curl, CURLOPT_URL, "https://www.somewhere.on.the.net/license.txt") or die("setopt URL failed");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1) or die("setopt RETURNTRANSFER failed");
curl_setopt($curl, CURLOPT_VERBOSE, true) or die("setopt VERBOSE failed");
curl_setopt($curl, CURLOPT_STDERR, fopen('C:/WWW/curl.txt', 'w+')) or die("setopt STDERR failed");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true) or die("setopt FOLLOWLOCATION failed");
$return_str = curl_exec($curl) or die("exec failed");
curl_close($curl);
echo $return_str;
?>

It always prints 'exec failed'. In its verbose log, Curl reports:

  • Trying 1.1.1.2:443...
  • Connected to www.somewhere.on.the.net (1.1.1.2) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: C:/Program Files/PHP/extras/ssl/cacert.pem
  • CApath: none
  • SSL certificate problem: unable to get local issuer certificate
  • Closing connection 0

The site uses a Letsencrypt certificate. Where should I look for the resolution to the above error?

0 Answers
Related