60:SSL证书:证书chainbool中的自签名证书
我尝试使用我的正确APP_ID,APP_SECRET等发送curl请求到
I try to send curl request with my correct APP_ID, APP_SECRET etc. to the
https://oauth.vk.com/access_token?client_id=APP_ID&client_secret=APP_SECRET&code=7a6fa4dff77a228eeda56603b8f53806c883f011c40b72630bb50df056f6479e52a&redirect_uri=REDIRECT_URI
需要从它获取access_token,但得到一个FALSE和 curl_error()
打印下一条消息否则:
I need to get access_token from it, but get a FALSE and curl_error()
print next message otherwise:
60: SSL certificate problem: self signed certificate in certificate chain
我的代码是:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
if ( ! $output) {
print curl_errno($ch) .': '. curl_error($ch);
}
// close curl resource to free up system resources
curl_close($ch);
return $output;
当我手动移动到上面的链接,我得到access_token很好。为什么它不工作curl?
When I move manually to the link above, I get access_token well. Why it doesn't work with curl? Help, please.
由于协议是https,因此对于开发模式 curl选项以避免ssl验证错误作为快速解决方案。
Since the protocol is https, For the development mode you can set this curl option to avoid ssl verification errors as a quick solution.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
但对于您的生产环境,不要使用此简单修复进行部署。它会导致一个安全问题,因为数据传输在网络层之间是透明的。请参阅以下网址中的正确修复部分:
But for your production environment, do not deploy with this easy fix. It will cause you a security issue as the data transfer will be transparent among the network layers. See the section proper fix from the following url:
http://unitstep.net/blog/2009/05/05/using-curl- in-php-to-access-https-ssltls-protected-sites /