php curl 获取https请求的2种方法


今天一个同事反映,使用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

http://curl.haxx.se/ca/cacert.pem

放到 程序文件目录

curl 增加下面的配置

http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/


« 
» 

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3