Compare commits

..

No commits in common. "master" and "v1.2.77" have entirely different histories.

View File

@ -338,26 +338,13 @@ abstract class BasicWePay
}
$signature = '';
if (!openssl_sign($data, $signature, $pkeyid, 'sha256WithRSAEncryption')) {
$this->freeKey($pkeyid);
openssl_free_key($pkeyid);
throw new InvalidArgumentException("Failed to sign data with private key");
}
$this->freeKey($pkeyid);
openssl_free_key($pkeyid);
return base64_encode($signature);
}
/**
* 兼容释放 OpenSSL 密钥资源
* @param mixed $pkey
* @return void
*/
protected function freeKey($pkey)
{
// PHP 8+ 中 openssl_free_key 已废弃,交由运行时回收即可。
if (version_compare(PHP_VERSION, '8.0.0', '<') && function_exists('openssl_free_key')) {
openssl_free_key($pkey);
}
}
/**
* 通过CURL模拟网络请求
* @param string $method 请求方法
@ -532,4 +519,4 @@ abstract class BasicWePay
throw new InvalidDecryptException('Rsa Encrypt Error.');
}
}
}
}