From 12dbcf79bcaabc8b0731ae7bf809cc69a6ea11d0 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Thu, 28 Nov 2019 10:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/payment/Weixin.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/extend/payment/Weixin.php b/extend/payment/Weixin.php index 71e81fd28..11d93aba7 100755 --- a/extend/payment/Weixin.php +++ b/extend/payment/Weixin.php @@ -694,14 +694,24 @@ class Weixin $apiclient_cert_file = ROOT.'runtime'.DS.'temp'.DS.'payment_weixin_pay_apiclient_cert.pem'; $apiclient_key_file = ROOT.'runtime'.DS.'temp'.DS.'payment_weixin_pay_apiclient_key.pem'; - $apiclient_cert = "-----BEGIN CERTIFICATE-----\n"; - $apiclient_cert .= wordwrap($this->config['apiclient_cert'], 64, "\n", true); - $apiclient_cert .= "\n-----END CERTIFICATE-----"; + if(stripos($this->config['apiclient_cert'], '-----') === false) + { + $apiclient_cert = "-----BEGIN CERTIFICATE-----\n"; + $apiclient_cert .= wordwrap($this->config['apiclient_cert'], 64, "\n", true); + $apiclient_cert .= "\n-----END CERTIFICATE-----"; + } else { + $apiclient_cert = $this->config['apiclient_cert']; + } file_put_contents($apiclient_cert_file, $apiclient_cert); - $apiclient_key = "-----BEGIN PRIVATE KEY-----\n"; - $apiclient_key .= wordwrap($this->config['apiclient_key'], 64, "\n", true); - $apiclient_key .= "\n-----END PRIVATE KEY-----"; + if(stripos($this->config['apiclient_key'], '-----') === false) + { + $apiclient_key = "-----BEGIN PRIVATE KEY-----\n"; + $apiclient_key .= wordwrap($this->config['apiclient_key'], 64, "\n", true); + $apiclient_key .= "\n-----END PRIVATE KEY-----"; + } else { + $apiclient_key = $this->config['apiclient_key']; + } file_put_contents($apiclient_key_file, $apiclient_key); return ['cert' => $apiclient_cert_file, 'key' => $apiclient_key_file]; -- GitLab