| 
 | 
 
 
            今天一个同事反映,使用curl发起https请求的时候报错:“SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed” 
很明显,验证证书的时候出现了问题。 
使用curl如果想发起的https请求正常的话有2种做法: 
方法一、设定为不验证证书和host。 
在执行curl_exec()之前。设置option 
[U]复制代码[/U] 代码如下: 
$ch = curl_init(); 
...... 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
方法二、设定一个正确的证书。 
本地ssl判别证书太旧,导致链接报错ssl证书不正确。 
我们需要下载新的ssl 本地判别文件 
http://curl.haxx.se/ca/cacert.pem 
放到 程序文件目录 
curl 增加下面的配置 
[U]复制代码[/U] 代码如下: 
   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true); ; 
   curl_setopt($ch,CURLOPT_CAINFO,dirname(__FILE__).'/cacert.pem'); 
大功告成 
(本人验证未通过。。。报错信息为:SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed) 
如果对此感兴趣的话可以参看国外一大神文章。http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ 
             
             
您可能感兴趣的文章:使用PHP模拟HTTP认证php下通过伪造http头破解防盗链的代码重新封装zend_soap实现http连接安全认证的php代码php使用curl访问https示例分享php之curl实现http与https请求的方法PHP中基本HTTP认证技巧分析PHP实现HTTP断点续传的方法PHP中file_get_contents函数抓取https地址出错的解决方法(两种方法)PHP中Http协议post请求参数PHP使用socket发送HTTP请求的方法PHP HTTP 认证实例详解 
         |   
 
 
 
 |