1
0
Эх сурвалжийг харах

[WeChatPay.V3] 修正 配置p12证书,无法解密敏感信息。

Roc 2 жил өмнө
parent
commit
a6487686b0

+ 7 - 7
src/Essensoft.Paylink.WeChatPay/V3/WeChatPayClient.cs

@@ -180,7 +180,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
             }
 
             // 解密敏感信息
-            DecryptPrivacyProperty(response, options.APIPrivateKey);
+            DecryptPrivacyProperty(response, options.RSAPrivateKey);
 
             return response;
         }
@@ -222,7 +222,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
             }
 
             // 解密敏感信息
-            DecryptPrivacyProperty(response, options.APIPrivateKey);
+            DecryptPrivacyProperty(response, options.RSAPrivateKey);
 
             return response;
         }
@@ -324,7 +324,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
         /// <remarks>
         /// <para><a href="https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml">敏感信息加解密</a></para>
         /// </remarks>
-        private static void DecryptPrivacyProperty(WeChatPayObject obj, string privateKey)
+        private static void DecryptPrivacyProperty(WeChatPayObject obj, RSA rsa)
         {
             foreach (var propertyInfo in obj.GetType().GetProperties())
             {
@@ -344,7 +344,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
                     }
 
                     // 解密并将明文设置回对象
-                    var ciphertext = OaepSHA1WithRSA.Decrypt(strValue, privateKey);
+                    var ciphertext = OaepSHA1WithRSA.Decrypt(rsa, strValue);
                     propertyInfo.SetValue(obj, ciphertext);
                 }
                 else if (propertyInfo.PropertyType.IsClass) // 解密子对象
@@ -355,7 +355,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
                         {
                             foreach (var item in array)
                             {
-                                DecryptPrivacyProperty(item, privateKey);
+                                DecryptPrivacyProperty(item, rsa);
                             }
                         }
                     }
@@ -365,7 +365,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
                         {
                             foreach (var item in enumerable)
                             {
-                                DecryptPrivacyProperty(item, privateKey);
+                                DecryptPrivacyProperty(item, rsa);
                             }
                         }
                     }
@@ -373,7 +373,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
                     {
                         if (propertyInfo.GetValue(obj) is WeChatPayObject wcpObj)
                         {
-                            DecryptPrivacyProperty(wcpObj, privateKey);
+                            DecryptPrivacyProperty(wcpObj, rsa);
                         }
                     }
                 }