当前位置: 动力学知识库 > 问答 > 编程问答 >

php - PHPcURL Error (60): SSL certificate issues: unable to get local issuer certificate

问题描述:

I am doing an api call which is seemingly throwing some errors. So basicall my script is doing a SOAP API post call using cURL and it throws an error that (60): SSL certificate problem: unable to get local issuer certificate

I have tried

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

but its not working.

I have also tried the following:

 $ch = curl_init(); // initialize curl handle

//curl_setopt($ch, CURLOPT_PROXY, $proxy);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

curl_setopt($ch, CURLOPT_CAINFO, "GeoTrustGlobalCA.crt");

curl_setopt($ch, CURLOPT_URL, $ENDPOINT);

curl_setopt($ch, CURLOPT_FAILONERROR, 0);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);

curl_setopt($ch, CURLOPT_TIMEOUT, 50);

curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

//curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

//curl_setopt($ch, CURLOPT_PORT, 80);

$data = curl_exec($ch);

$curl_errno = curl_errno($ch);

$curl_error = curl_error($ch);

if ($curl_errno > 0) {

echo "cURL Error ($curl_errno): $curl_error\n";

} else {

echo "Data received. To complete this transaction, enter your Bonga PIN on your handset. if you don't have one dial *126*5# for instructions\n";

echo $data;

}

curl_close($ch);

Nothing seems to be working. Any workarounds? Btw the $ENDPOINT is https://safaricom.co.ke

网友答案:

The site has several errors, like mismatch of the name (should be www.safaricom.co.ke not safaricom.co.ke) and also an incomplete certificate chain and additionally a very insecure setup. No wonder the validation fails. Some browsers work when the correct name was used because they work around missing chain certificates. Other clients (like curl) and most mobile browsers will not work because they expect the site to be properly set up.

For detailed information see the SSLabs report.

分享给朋友:
您可能感兴趣的文章:
随机阅读: