0

I'm getting the following error when using curl: Error:60 SSL certificate problem: unable to get local issuer certificate.

<?php
if($fp = tmpfile())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://server.org");
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_CERTINFO, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
$result = curl_exec($ch);
curl_errno($ch)==0 or die("Error:".curl_errno($ch)." ".curl_error($ch));
fseek($fp, 0);//rewind
$str='';
while(strlen($str.=fread($fp,8192))==8192);
echo $str;
fclose($fp);
}
?>

I know this is due to curl needing a ca.pem file however when I added curl.cainfo = "c:\xampp\htdocs\openssl\cas\cacert.pem" to my php.ini file and restarted the services it still doesn't work and this would be becuase the server in question is internal and using a chain file certificates from my PKI servers does anyone know of a way to get this working for internal other than changing this: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); to this: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); ?

user2914877
  • 53
  • 2
  • 4
  • What version of PHP are you using? Take a look at https://stackoverflow.com/q/23392159/3794472, possibly related. – Jeremiah Winsley Jul 29 '15 at 18:27
  • Php 5.6.11, I'll have a look now. – user2914877 Jul 30 '15 at 08:07
  • Sadly it doesn't looks like its that issue. It's more likely its a problem with the fact that its an internal issuing CA and chain of certs. Going to test on an external source just for peace of mind if nothing else. – user2914877 Jul 30 '15 at 08:12
  • Definitely only a problem with internally signed SSL certs works fine externally. – user2914877 Jul 30 '15 at 08:15
  • Debugging with `CURLOPT_VERBOSE` as shown in https://stackoverflow.com/q/15558520/3794472 may help narrow down the problem, that will at least tell you why it's rejecting it. – Jeremiah Winsley Jul 30 '15 at 16:22
  • Take a look at http://stackoverflow.com/questions/24923604/guzzle-curl-error-60-ssl-unable-to-get-local-issuer?rq=1 – Bizmate Sep 29 '15 at 23:54

0 Answers0