yansongda / pay

可能是我用过的最优雅的 Alipay/WeChat/Douyin/Unipay/江苏银行 的支付 SDK 扩展包了
http://pay.yansongda.cn
MIT License
5.04k stars 1.03k forks source link

为什么都是获取证书,公钥和私钥要区别对待呢? #1017

Closed cjango closed 2 months ago

cjango commented 2 months ago
function get_public_cert(string $key): string
{
    return is_file($key) ? file_get_contents($key) : $key;
}

function get_private_cert(string $key): string
{
    if (is_file($key)) {
        return file_get_contents($key);
    }

    return "-----BEGIN RSA PRIVATE KEY-----\n".
        wordwrap($key, 64, "\n", true).
        "\n-----END RSA PRIVATE KEY-----";
}
yansongda commented 2 months ago

https://github.com/yansongda/pay/blob/master/tests/FunctionTest.php#L61-L75