WAMP安装curl扩展并发起https请求
wamp安装curl扩展的方法:
http://blog.csdn.net/superuser007/article/details/5781095
安装出现 PHP Extension "curl" must be loaded 错误。
解决方法如下:
1> 在 WAMP或XAMPP 目录下“搜索”功能查找到 httpd.conf:
把
#LoadModule rewrite_module modules/mod_rewrite.so
改
LoadModule rewrite_module modules/mod_rewrite.so
(只是去除 # 号)
2> 用上面同样的方法查找到 php.ini( 这里可能有两个 php.ini 文件,两个都要改 )
把
;extension=php_mcrypt.dll
改
extension=php_mcrypt.dll
把
;extension=php_curl.dll
改
extension=php_curl.dll
把
;extension=php_pdo_mysql.dll
改
extension=php_pdo_mysql.dll
( 只是去除 ; )
http 使用curl发起https请求
今天一个同事反映,使用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
$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 增加下面的配置
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/
为了防止某天该文章被Q今复制过来。内容如下:
Using cURL in PHP to access HTTPS (SSL/TLS) protected sites
From PHP, you can access the useful cURL Library (libcurl) to make requests to URLs using a variety of protocols such as HTTP, FTP, LDAP and even Gopher. (If you’ve spent time on the *nix command line, most environments also have the curl
command available that uses the libcurl library)
In practice, however, the most commonly-used protocol tends to be HTTP, especially when using PHP for server-to-server communication. Typically this involves accessing another web server as part of a web service call, using some method such as XML-RPC or REST to query a resource. For example, Delicious offers a HTTP-based API to manipulate and read a user’s posts. However, when trying to access a HTTPS resource (such as the delicious API), there’s a little more configuration you have to do before you can get cURL working right in PHP.
The problem
// Initialize session and set URL.
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
If $url
points toward an HTTPS resource, you’re likely to encounter an error like the one below:
Failed: Error Number: 60. Reason: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
The quick fix
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
The proper fix
Then click on “View Certificate”:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/BuiltinObjectToken-EquifaxSecureCA.crt");
The other option I’ve included, CURLOPT_SSL_VERIFYHOST
can be set to the following integer values:
- 0: Don’t check the common name (CN) attribute
- 1: Check that the common name attribute at least exists
- 2: Check that the common name exists and that it matches the host name of the server
More information
WAMP安装curl扩展并发起https请求相关推荐
- php curl 发送https请求失败,php的curl扩展无法发起https请求
很奇怪的是,file_get_content函数可以对https地址发起请求并且收到响应报文,但是curl就不可以,这是什么原因呢?我已经安装了openssl扩展. function fetch($u ...
- http 使用curl发起https请求
今天一个同事反映,使用curl发起https请求的时候报错:"SSL certificate problem, verify that the CA cert is OK. Details: ...
- 用curl发起https请求
使用curl发起https请求 使用curl如果想发起的https请求正常的话有2种做法: 方法一.设定为不验证证书和host. 在执行curl_exec()之前.设置option $ch = cur ...
- http 使用curl发起https请求 error 60 51
curl_setopt换成 curl_easy_setopt cacert.pem路径换成字符串 CURLOPT_SSL_VERIFYHOST 解决error 51 大概7.28版本后要设置2,不是 ...
- php+安装+curl_linux php安装curl扩展的方法
linux php安装curl扩展的方法:首先进入php源码目录,执行phpize生成配置文件:然后调用configure生成Makefile文件:接着通过命令"make install&q ...
- php查看curl扩展重新安装,关于php安装curl扩展
php安装curl扩展的方法:首先下载源码包并解压:然后进行预编译并指定安装位置:接着通过"make && make install"安装扩展:最后修改php.in ...
- nginx php curl扩展,关于php安装curl扩展
php安装curl扩展的方法:首先下载源码包并解压:然后进行预编译并指定安装位置:接着通过"make && make install"安装扩展:最后修改php.in ...
- 安装php的curl扩展,学习猿地-关于php安装curl扩展
php安装curl扩展的方法:首先下载源码包并解压:然后进行预编译并指定安装位置:接着通过"make && make install"安装扩展:最后修改php.in ...
- linux php curl 安装包下载,linux中php如何安装CURL扩展方法
如果php已经在系统编译好,后来又需要添加新的扩展. 一种方式就是重新完全编译php,另一种方式就是单独编译扩展库,以extension的形式扩展. 下面以安装curl扩展为例: 1.下载curl安装 ...
最新文章
- 个人中心数据接口的开发
- android+webview+打不开,webview 在android下无法打开 ?是否为一个bug?请帮忙看下!谢谢!...
- oracle json字符串转数组,json字符串转化成json对象(原生方法)
- javaone_虚拟化Java应用程序:最佳实践(JavaOne 2011)
- Java编写代理服务器(Burp拦截Demo)一
- 简明 Python 教程学习笔记_7_文件操作(os、shutil、pathlib )
- 再谈拍照,OPPO这次拿什么和iPhone7拼?
- HDU 4293 Groups (线性dp)
- Linux目录/usr/bin和 /usr/local/bin区别
- MyEclipse 8.5配置Tomcat 7.0
- 网络安全法对计算机人员的影响,网络安全法的基本原则-网络安全论文-计算机论文.docx...
- 客户画像、精准营销与数字化运营
- java math.min_Java Math.min() 方法
- Appium+python自动化(七)- 初识琵琶女Appium(千呼万唤始出来,犹抱琵琶半遮面)- 上(超详解)...
- PS2021安装教程视频方法(附个人详细安装教程)windows版本
- 直观打印二叉树的图形
- 基于xilinx fpga的ofdm通信系统基带设计_基于嵌入式Wi-Fi处理器的无线系统设计...
- 如何配置crontab每天早上6点和7点执行脚本
- 英语学习详细笔记(三)代名词
- 形式系统(Formale System)-SAT问题