Skip to content

Commit

Permalink
[WeChatPay.V3] 修正 .NET 9 下载解析平台证书 #182
Browse files Browse the repository at this point in the history
  • Loading branch information
roc916 committed Nov 25, 2024
1 parent 370b1c8 commit 3e7feb9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task<WeChatPayPlatformCertificate> GetCertificateAsync(IWeChatPayCl
{
var certStr = AEAD_AES_256_GCM.Decrypt(certificate.EncryptCertificate.Nonce, certificate.EncryptCertificate.Ciphertext, certificate.EncryptCertificate.AssociatedData, options.APIv3Key);
#if NET9_0_OR_GREATER
var x509cert = X509CertificateLoader.LoadPkcs12(Encoding.UTF8.GetBytes(certStr), string.Empty, X509KeyStorageFlags.DefaultKeySet | X509KeyStorageFlags.Exportable);
var x509cert = X509CertificateLoader.LoadCertificate(Encoding.UTF8.GetBytes(certStr));
#else
var x509cert = new X509Certificate2(Encoding.UTF8.GetBytes(certStr), string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
#endif
Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task<WeChatPayPlatformCertificate> GetCertificateAsync(IWeChatPayCl
{
var certStr = AEAD_AES_256_GCM.Decrypt(certificate.EncryptCertificate.Nonce, certificate.EncryptCertificate.Ciphertext, certificate.EncryptCertificate.AssociatedData, options.APIv3Key);
#if NET9_0_OR_GREATER
var x509cert = X509CertificateLoader.LoadPkcs12(Encoding.UTF8.GetBytes(certStr), string.Empty, X509KeyStorageFlags.DefaultKeySet | X509KeyStorageFlags.Exportable);
var x509cert = X509CertificateLoader.LoadCertificate(Encoding.UTF8.GetBytes(certStr));
#else
var x509cert = new X509Certificate2(Encoding.UTF8.GetBytes(certStr), string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
#endif
Expand Down

0 comments on commit 3e7feb9

Please sign in to comment.