mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-03-10 00:13:36 +08:00
fix(tenpayv2): 修复 Windows 环境下潜在的证书加载失败问题
This commit is contained in:
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net461; netstandard2.0; net6.0</TargetFrameworks>
|
<TargetFrameworks>net461; net471; netstandard2.0; net6.0</TargetFrameworks>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>8.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System.Net.Http.WebRequest" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net47'" />
|
<Reference Include="System.Net.Http.WebRequest" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net471'" />
|
||||||
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net47'" />
|
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net471'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Net.Http;
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Settings
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Settings
|
||||||
@@ -27,7 +29,25 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Settings
|
|||||||
|
|
||||||
if (_certBytes != null)
|
if (_certBytes != null)
|
||||||
{
|
{
|
||||||
X509Certificate x509 = (_certPassword == null) ? new X509Certificate2(_certBytes) : new X509Certificate2(_certBytes, _certPassword);
|
X509Certificate x509;
|
||||||
|
|
||||||
|
#if NET471_OR_GREATER || NET5_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
#else
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
x509 = (_certPassword == null)
|
||||||
|
? new X509Certificate2(_certBytes)
|
||||||
|
: new X509Certificate2(_certBytes, _certPassword, X509KeyStorageFlags.MachineKeySet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x509 = (_certPassword == null)
|
||||||
|
? new X509Certificate2(_certBytes)
|
||||||
|
: new X509Certificate2(_certBytes, _certPassword);
|
||||||
|
}
|
||||||
|
|
||||||
handler.ClientCertificates.Add(x509);
|
handler.ClientCertificates.Add(x509);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net461; net47; netstandard2.0; net6.0</TargetFrameworks>
|
<TargetFrameworks>net461; net471; netstandard2.0; net6.0</TargetFrameworks>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>8.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net47'" />
|
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net471'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user