Home > php教程 > php手册 > body text

微信公众号红包接口开发PHP开发 CA证书出错,请登陆微信支付商户平台下载证书

WBOY
Release: 2016-06-06 09:53:27
Original
2025 people have browsed it

微信红包接口调试过程中一直提示“CA证书出错,请登陆微信支付商户平台下载证书”,经反复调试,大致解决方法如下:

1.首先确保CA证书的路径是否正确,一定得是绝对路径,因为是PHP开发的,这里需要三个pem证书

2.确保服务器支持,新浪云的sae,经测试支持不是很好,一直报错,换用其他服务器后,一次通过

 

POST红包证书的代码部分如下:

function post( $strXml) {

$url='https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

//因为微信红包在使用过程中需要验证服务器和域名,故需要设置下面两行
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // 只信任CA颁布的证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 检查证书中是否设置域名,并且是否与提供的主机名匹配


curl_setopt($ch, CURLOPT_SSLCERT,'/var/www/html/hongbao/apiclient_cert.pem');
curl_setopt($ch, CURLOPT_SSLKEY,'/var/www/html/hongbao/apiclient_key.pem');
curl_setopt($ch, CURLOPT_CAINFO, '/var/www/html/hongbao/rootca.pem'); // CA根证书(用来验证的网站证书是否是CA颁布)


curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!