zoukankan      html  css  js  c++  java
  • 微信公众号红包接口开发PHP开发 CA证书出错,请登陆微信支付商户平台下载证书

    微信红包接口调试过程中一直提示“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;
    }

  • 相关阅读:
    Windows下输入法全角符,半角符的切换
    hdu 2546 饭卡
    hdu 1712 ACboy needs your help
    hdu 3033 I love sneakers!
    hdu 1171 Big Event in HDU
    hdu 1114 Piggy-Bank
    HDU 1058 Humble Numbers
    hdu 1297
    hdu 2050
    hdu 2563
  • 原文地址:https://www.cnblogs.com/kangjin0828/p/4517657.html
Copyright © 2011-2022 走看看