码迷,mamicode.com
首页 > 其他好文 > 详细

支付宝当面付的验证签名的坑

时间:2018-05-03 19:32:54      阅读:610      评论:0      收藏:0      [点我收藏+]

标签:获取   ali   cal   cbo   public   jsm   rap   zrc   open   

生成签名时
openssl_get_privatekey

$priKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($priKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
$res = openssl_get_privatekey($priKey);

========

验证签名时
如果上传的文件就是支付宝后台下载的公钥(不带头尾的一行字符串),
那不需要再用
openssl_get_publickey
获取一次了。。
$res = "-----BEGIN PUBLIC KEY-----\n" .
wordwrap($pubKey, 64, "\n", true) .
"\n-----END PUBLIC KEY-----";
file_put_contents(HOME_DIR.‘/pay_alipayqrcode_callback.txt‘,date("Y-m-d H:i:s")."-pubKey:"."\r\n".var_export($res,true)."\r\n",FILE_APPEND);
//$res = openssl_get_publickey($pubKey);不需要再获取一次了。。

openssl_get_publickey适用于文件如下格式的
格式如这样的

-----BEGIN CERTIFICATE-----
MIICMTCCAZqgAwIBAgIKe5fKECdaAADZnTANBgkqhkiG9w0BAQUFADAcMQwwCgYD
VQQDEwNBQkMxDDAKBgNVBAoTA0FCQzAeFw0wNDAxMDUwNTQ5NDRaFw0yMzA4MTEw
NTM4NDlaMEExGDAWBgNVBAMTD01haW5TZXJ2ZXIuMDAwMTEXMBUGA1UECxMOUGF5
bWVudEdhdGV3YXkxDDAKBgNVBAoTA0FCQzCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEA//+Bv7geZqme6BCLboRzBNIlotyQ0qnaZjxRwjHM14SvjmiQK1+lJ4lJ
2RQFOIkakr7zDvscqs7HyShP3LnPK9c9nsIypM0YOtp/LdqmxqmOcBoB6Z43WJp5
0JMaC0w1UBEumX+wtPaa4JsoE99SEEQbJ29T+XFBLsvStT8DjRECAwEAAaNVMFMw
QAYDVR0fBDkwNzA1oDOgMaQvMC0xDzANBgNVBAMTBmNybDE4NjEMMAoGA1UECxMD
Y3JsMQwwCgYDVQQKEwNBQkMwDwYDVR1jBAgDBgD/AAAAADANBgkqhkiG9w0BAQUF
AAOBgQCZtKSPwnI+SMAu4RFUVIgRd/JRD45hqjMuK9Lux96sylRTwUJrn+0xj4P1
RXuKiMG/ldka8REsnCv7kX+OyEAAfN6xb1p+lykrJk+YvqJqPRkBhNVLoQostzdZ
wbUrApnELD+xLm0F6BRK/zRcz0H+2kI8L34OwOXm8NVXLnNF3Q==
-----END CERTIFICATE-----

支付宝当面付的验证签名的坑

标签:获取   ali   cal   cbo   public   jsm   rap   zrc   open   

原文地址:https://www.cnblogs.com/showker/p/8986730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!