先说一下,生成rsa 私钥 公钥的方法,以ubuntu 为例
sudo apt-get install openssl # 先装上这个库
genrsa -out rsa_private_key.pem 1024  #生成1024长度的私钥, 支付宝的 rsa2 要求是 2048长度,这里可以修改一下
rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem #使用刚才生成的私钥,生成一个配对的公钥

使用 支付宝电脑支付,提供的sdk ,配置好 config.php 中的 appid ,支付同步、异步地址、配置支付宝私钥等后,打开浏览器测试,报一个waring openssl_sign(): supplied key param cannot be coerced into a private key 检查代码发现

protected function sign($data, $signType = "RSA") {
        if($this->checkEmpty($this->rsaPrivateKeyFilePath)){
            $priKey=$this->rsaPrivateKey;
            $res = "-----BEGIN RSA PRIVATE KEY-----\n" .
                wordwrap($priKey, 64, "\n", true) .
                "\n-----END RSA PRIVATE KEY-----";
        }else {
            $priKey = file_get_contents($this->rsaPrivateKeyFilePath);
            $res = openssl_get_privatekey($priKey);
        }

支付宝openssl_sign(): supplied key param cannot be coerced into a private key in

 

 

这里帮你,做了添加头部,结束和换行的处理,所以,你必须要配置的私钥,里面不能有这些,就是只能长在一行里面写好。

相关文章:

  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-08-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案