Home  >  Article  >  PHP Framework  >  thinkphp website Alipay asynchronous callback signature verification failure problem

thinkphp website Alipay asynchronous callback signature verification failure problem

藏色散人
藏色散人forward
2020-07-03 13:26:583334browse

The following tutorial column of thinkphp framework will introduce to you the problem of Alipay asynchronous callback signature verification failure on the thinkphp website. I hope it will be helpful to friends in need!

thinkphp website Alipay asynchronous callback signature verification failure problem

A project at hand uses Alipay mobile website payment. The project is made with TP. After downloading the Alipay SDK and modifying it, it can be called up normally. The synchronous interface can also be accessed, but it is asynchronous. The interface signature verification always fails with an error. It is traced to line 580 of AopClient.php, and

if ("RSA2" == $signType) {
    $result = (bool) openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256);//这句报错
} else {
    $result = (bool) openssl_verify($data, base64_decode($sign), $res);
}

is printed at the bottom of the code. print_r(openssl_error_string());, The output is

error:0906D06C:PEM routines:PEM_read_bio:no start line

Baidu has no results. Some people say that the certificate is wrong. It is useless to change the certificate myself.

Later, I accidentally discovered that there was a problem with the input, and finally found a reason:

When receiving Alipay asynchronous notifications, the I function cannot be used

$data=I("post.");//项目中这样写,导致支付宝传来的数据部分特殊字符被过滤,具体主要是fund_bill_list和sign这两部分
$data=$_POST;//写成这样就好了

One more thing:

No matter whether the signature verification is correct or not, openssl_error_string() always outputs error:0906D06C:PEM routines:PEM_read_bio:no start line. This is my situation and I have not delved into the details. .

The above is the detailed content of thinkphp website Alipay asynchronous callback signature verification failure problem. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete