Recently I worked on the Alipay service window for a customer and encountered an error:
Warning: openssl_sign() [function.openssl-sign]: Unknown signature algorithm. in
After checking, I found that the PHP environment on my server supports openssl_sign() but does not support parameters such as OPENSSL_ALGO_SHA256. After asking the boss, I found that this parameter is only supported in php5.4.8 or above, and lower versions are I used SHA256, so I tried it and got it!
The reason for the error is that the AopClient.php file in Alipay's demo uses such a statement:
if ("RSA2" == $signType) {
openssl_sign($data, $sign, $res,OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $sign, $ res);
}
The solution is to change OPENSSL_ALGO_SHA256 to SHA256
if ( "RSA2" == $signType) {
openssl_sign($data, $sign, $res,SHA256);
} else {
openssl_sign($data, $sign, $res);
}
Note: There are three places in this file, all must be modified!
The above is the detailed content of Alipay service window php demo reports error Warning: openssl_sign() [function.openssl.... For more information, please follow other related articles on the PHP Chinese website!