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); ?