Micro-channel pay: curl error, error code: 60

A recent project uses micro-channel micro-channel payment system, in a micro-channel official download official demo. Even after being given the run.

Fatal error: Uncaught exception ‘WxPayException‘ with message ‘curl出错,错误码:60‘ in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php:564 Stack trace: #0 D:\wwwroot\weixinpaytest\lib\WxPay.Api.php(62):

WxPayApi::postXmlCurl(‘<xml><appid><![...‘, ‘https://api.mch...‘, false, 6) #1 D:\wwwroot\weixinpaytest\pay\jsapi.php(36):

WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder)) #2 {main} thrown in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php on line 564

After check online to no avail, only then to find inside the micro-channel official document solutions. Preliminary judge for the wrong curl respect. Server-side data is grab a situation that may arise.

Later in the official document inside a micro-channel pay "Notes" link below https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_2

Notes of the first found an important message. Original excerpt follows:

1, the server SSL Imprint

Due to the low presence of high-risk vulnerabilities version of SSL, SSL needs to verify your version used by the system need to be upgraded description is available in the public platform SSL security policy Description: https: //mp.weixin.qq.com/cgi-bin/announce ? action = getannouncement & key = 1414562353 & version = 11 & lang = zh_CN

Java developers can refer to the description Oracle website: [Oracle Java disable SSL3] (http://www.oracle.com/technetwork/java/javase/documentation/cve-2014-3566-2342133.html) 

According to the text of the link, open to find a solution given by the official.

示例1(php):
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);

Find the following code to WxPay.Api.php file (about 357-358 lines):

curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt ($ CH, CURLOPT_SSL_VERIFYHOST, 2); // strict check

Amended as follows

if(stripos($url,"https://")!==FALSE){
        curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        }    else    {
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验

Tested perfect solution, hoping to be able to modify the official micro-channel out of this bug as soon as possible. We hope to do better and better micro-channel.


Original: https: //blog.csdn.net/qq_34755805/article/details/51221932 

Guess you like

Origin www.cnblogs.com/init-007/p/11240745.html