Home > Backend Development > PHP Tutorial > php curl https ssl 证书问题

php curl https ssl 证书问题

WBOY
Release: 2016-06-23 14:38:48
Original
1747 people have browsed it

CURL代码:
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //信任任何证书
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 检查证书中是否设置域名,0不验证
curl_setopt($curl, CURLOPT_VERBOSE, 1); //debug模式
curl_setopt($curl, CURLOPT_SSLCERT, "./keys/client.crt"); //client.crt文件路径
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, "112358"); //client证书密码
curl_setopt($curl, CURLOPT_SSLKEY, "./keys/client.key");

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

一直返回 int 58 这个CURL错误
int 58
unable to use client certificate (no key found or wrong pass phrase?)

把证书重新生成了一次,还是不行
本地环境 WAMP 生成的证书直接在IE浏览器上安全是可以访问的
有没有同学遇到过呢?


回复讨论(解决方案)

自己解决了,之前是证书生成的不对,现在是路径写的不对……

这段代码先保留了。以后参考。

想问下,client.crt和client.key是怎么获得的呢,对方只给了我p12文件和一个crt文件

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template