微信支付,添加微信支付证书发生异常,提示error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure

发布时间 2023-05-04 23:29:25作者: zhaok
 1 BaseException
 2     Message:error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure
 3     StackTrace:
 4     InnerException:error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure
 5     InnerException.StackTrace:   at Internal.Cryptography.Pal.OpenSslPkcs12Reader.Decrypt(SafePasswordHandle password)
 6    at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs12(OpenSslPkcs12Reader pfx, SafePasswordHandle password, Boolean single, ICertificatePal& readPal, List`1& readCerts)
 7    at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs12(SafeBioHandle bio, SafePasswordHandle password, Boolean single, ICertificatePal& readPal, List`1& readCerts, Exception& openSslException)
 8    at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromBio(SafeBioHandle bio, SafePasswordHandle password)
 9    at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
10    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
11    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
12    at Senparc.Weixin.TenPay.V3.TenPayV3InfoCollection.Register(TenPayV3Info tenPayV3Info, String name)

项目里用到了盛派,出现这个问题是因为配置文件中证书密码字段名变了,原先是TenPayV3_CertPassword,现在变成了TenPayV3_CertSecret,所以加载证书时导致密码不对,无法正常加载,特此记录一下,防止忘记。