Skip to content

Commit 06b3f2c

Browse files
committed
fix: 更新平台证书下载及证书读取
1 parent 989fd68 commit 06b3f2c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

WePayV3/Cert.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ class Cert extends BasicWePay
4242
public function download()
4343
{
4444
try {
45-
$aes = new DecryptAes($this->config['mch_v3_key']);
46-
$result = $this->doRequest('GET', '/v3/certificates');
4745
$certs = [];
46+
$result = $this->doRequest('GET', '/v3/certificates');
47+
$decrypt = new DecryptAes($this->config['mch_v3_key']);
4848
foreach ($result['data'] as $vo) {
4949
$certs[$vo['serial_no']] = [
5050
'expire' => strtotime($vo['expire_time']),
51-
'content' => $aes->decryptToString(
51+
'serial' => $vo['serial_no'],
52+
'content' => $decrypt->decryptToString(
5253
$vo['encrypt_certificate']['associated_data'],
5354
$vo['encrypt_certificate']['nonce'],
5455
$vo['encrypt_certificate']['ciphertext']

WePayV3/Contracts/BasicWePay.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ protected function signVerify($data, $sign, $serial)
367367
protected function _getCert($serial = '')
368368
{
369369
$certs = $this->tmpFile("{$this->config['mch_id']}_certs");
370-
if (empty($certs) || empty($certs[$serial]['content'])) {
370+
if (empty($certs) || empty($certs[$serial]['serial']) || empty($certs[$serial]['content'])) {
371371
Cert::instance($this->config)->download();
372372
$certs = $this->tmpFile("{$this->config['mch_id']}_certs");
373373
}
374374
foreach ($certs as $cert) {
375-
if ($certs[$serial]['expire'] > time()) {
375+
if ($cert[$serial]['expire'] > time() && !empty($cert['serial']) && !empty($cert['content'])) {
376376
$this->config['cert_package'][$cert['serial']] = $cert['content'];
377377
if (empty($this->config['mp_cert_serial'])) {
378378
$this->config['mp_cert_serial'] = $cert['serial'];

0 commit comments

Comments
 (0)