Skip to content

Commit

Permalink
[WeChatPay.V3] 修正平台证书 加密敏感信息
Browse files Browse the repository at this point in the history
  • Loading branch information
roc916 committed Nov 6, 2024
1 parent 3f63797 commit aa3e3f6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,16 @@ public async Task<WeChatPayPlatformCertificate> 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);
Expand Down

0 comments on commit aa3e3f6

Please sign in to comment.