来源:自学PHP网 时间:2015-04-14 12:58 作者: 阅读:次
[导读] 近期正在开发微信支付功能,用crul调用证书时提示类似错误 58problem with the local client certificate 经过查找手册和实验,参考php手册提供的以下方案可以解决,代码如下If you want...
近期正在开发微信支付功能,用crul调用证书时提示类似错误 58 problem with the local client certificate. 经过查找手册和实验,参考php手册提供的以下方案可以解决,代码如下 If you want to connect to a server which requires that you identify yourself with a certificate, use following code. Your certificate and servers certificate are signed by an authority whose certificate is in ca.ctr. <?php curl_setopt($ch, CURLOPT_VERBOSE, '1'); //启用时会汇报所有的信息,存放在STDERR或指定的 CURLOPT_STDERR 中。 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '2'); //2 检查公用名是否存在,并且是否与提供的主机名匹配。 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //cURL从服务端进行验证 curl_setopt($ch, CURLOPT_CAINFO, getcwd().'/cert/ca.crt'); curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/mycert.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'password'); ?> If your original certificate is in .pfx format, you have to convert it to .pem using following commands # openssl pkcs12 -in mycert.pfx -out mycert.key # openssl rsa -in mycert.key -out mycert.pem # openssl x509 -in mycert.key >> mycert.pem |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com