生成签名时
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-----
原文地址:https://www.cnblogs.com/showker/p/8986730.html