feat(tenpayv2): adapt to .NET 9.0

This commit is contained in:
Fu Diwei 2024-11-20 18:37:24 +08:00
parent 9644cf016f
commit ac34f57fd6
3 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462; net471; netstandard2.0; net6.0</TargetFrameworks>
<TargetFrameworks>net462; net471; netstandard2.0; net6.0; net9.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>

View File

@ -28,6 +28,9 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Settings
{
X509Certificate x509;
#if NET9_0_OR_GREATER
x509 = X509CertificateLoader.LoadPkcs12(certificateBytes, certificatePassword, X509KeyStorageFlags.UserKeySet | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
#else
#if NET471_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET5_0_OR_GREATER
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#else
@ -44,6 +47,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Settings
? new X509Certificate2(certificateBytes)
: new X509Certificate2(certificateBytes, certificatePassword, X509KeyStorageFlags.UserKeySet | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
}
#endif
#if NETCOREAPP2_1_OR_GREATER || NET5_0_OR_GREATER
handler.SslOptions.ClientCertificates = new X509CertificateCollection() { x509 };

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472; net6.0</TargetFrameworks>
<TargetFrameworks>net472; net6.0; net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>