mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2026-09-05 15:32:01 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5aff97be52 |
@ -338,13 +338,26 @@ abstract class BasicWePay
|
|||||||
}
|
}
|
||||||
$signature = '';
|
$signature = '';
|
||||||
if (!openssl_sign($data, $signature, $pkeyid, 'sha256WithRSAEncryption')) {
|
if (!openssl_sign($data, $signature, $pkeyid, 'sha256WithRSAEncryption')) {
|
||||||
openssl_free_key($pkeyid);
|
$this->freeKey($pkeyid);
|
||||||
throw new InvalidArgumentException("Failed to sign data with private key");
|
throw new InvalidArgumentException("Failed to sign data with private key");
|
||||||
}
|
}
|
||||||
openssl_free_key($pkeyid);
|
$this->freeKey($pkeyid);
|
||||||
return base64_encode($signature);
|
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模拟网络请求
|
* 通过CURL模拟网络请求
|
||||||
* @param string $method 请求方法
|
* @param string $method 请求方法
|
||||||
@ -519,4 +532,4 @@ abstract class BasicWePay
|
|||||||
throw new InvalidDecryptException('Rsa Encrypt Error.');
|
throw new InvalidDecryptException('Rsa Encrypt Error.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user