From aa3e3f63868d5ccbbbfedcf3ecffe622425ca96f Mon Sep 17 00:00:00 2001 From: Roc Date: Wed, 6 Nov 2024 15:32:52 +0800 Subject: [PATCH] =?UTF-8?q?[WeChatPay.V3]=20=E4=BF=AE=E6=AD=A3=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=AF=81=E4=B9=A6=20=E5=8A=A0=E5=AF=86=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V3/WeChatPayPlatformCertificateManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayPlatformCertificateManager.cs b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayPlatformCertificateManager.cs index e4096f3a3..9e83a3931 100644 --- a/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayPlatformCertificateManager.cs +++ b/src/Essensoft.Paylink.WeChatPay/V3/WeChatPayPlatformCertificateManager.cs @@ -112,13 +112,16 @@ public async Task GetCertificateAsync(IWeChatPayCl { var certStr = AEAD_AES_256_GCM.Decrypt(certificate.EncryptCertificate.Nonce, certificate.EncryptCertificate.Ciphertext, certificate.EncryptCertificate.AssociatedData, options.APIv3Key); + var x509cert = new X509Certificate2(Encoding.ASCII.GetBytes(certStr), string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); + var cert = new WeChatPayPlatformCertificate { MchId = options.MchId, SerialNo = certificate.SerialNo, EffectiveTime = DateTime.Parse(certificate.EffectiveTime), ExpireTime = DateTime.Parse(certificate.ExpireTime), - Certificate = new X509Certificate2(Encoding.ASCII.GetBytes(certStr), string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable) + Certificate = x509cert, + PublicKey = Convert.ToBase64String(x509cert.GetRSAPublicKey().ExportSubjectPublicKeyInfo()) }; _certs.TryAdd(certificate.SerialNo, cert);