我从https://curl.haxx.se/docs/caextract.html下载了证书,并指定了CURLOPT_CAINFO文件的完整路径
我一直收到错误 - 卷曲错误:SSL:证书验证失败(结果:5)
我使用的是Mac OS Sierra,10.12和PHP 7.0.11
我从哪里获得有效证书才能进行SSL API调用?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt ($ch, CURLOPT_CAINFO, "cacert.pem");
$result=curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);