always prompts openssl_sign (): supplied key param cannot be coerced into a private key. I changed the system and the local computer is WIN7, not even under the linux system?
someone on the network said that in the sandbox, the private key needs to be converted, and I report an error directly in the formal environment. At the same time, the public key verification is successful in Alipay.
$priKey=$this->rsaPrivateKey;
$res = "-----BEGIN RSA PRIVATE KEY-----" .PHP_EOL.
wordwrap($priKey, 64, "\n", true) .PHP_EOL.
"-----END RSA PRIVATE KEY-----";
($res) or die("RSA");
if ("RSA2" == $signType) {
openssl_sign($data, $sign, $res, version_compare(PHP_VERSION,"5.4.0", "<") ? SHA256 : OPENSSL_ALGO_SHA256);
} else {
openssl_sign($data, $sign, $res);
}
$sign = base64_encode($sign);
return $sign;
is WIN7 64-bit on the native, while the environment is phpstudy
I haven"t answered my question on OS for a long time. I don"t know why, but I have no direction at all.