zoukankan      html  css  js  c++  java
  • 支付宝当面付的验证签名的坑

    生成签名时
    openssl_get_privatekey

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

    ========

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

  • 相关阅读:
    redis4.0 安装
    MYSQL第一节:Mysql5.7 通用二进制安装方法
    mysql密码忘记,重新设置密码
    selenium使用
    数据结构
    Mysql数据库引擎的区别
    python中的mysql转义字符串(向mysql插入特殊字符)
    scrapyd使用
    liunx部署redis
    Django+uwsgi部署到liunx服务器上
  • 原文地址:https://www.cnblogs.com/showker/p/8986730.html
Copyright © 2011-2022 走看看