Skip to content

Commit 2d7e6ca

Browse files
authored
Merge branch 'main' into hoerup/goFF-cache
2 parents 6214c3d + 8e74bc9 commit 2d7e6ca

File tree

31 files changed

+267
-225
lines changed

31 files changed

+267
-225
lines changed

DotnetSdkContrib.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Contrib.Provide
3131
EndProject
3232
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Contrib.Providers.FeatureManagement.Test", "test\OpenFeature.Contrib.Providers.FeatureManagement.Test\OpenFeature.Contrib.Providers.FeatureManagement.Test.csproj", "{9EBB5E8F-9F05-4DFF-9E99-2BAA5D5325FB}"
3333
EndProject
34-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Contrib.Providers.Flagd.E2e.Test", "test\OpenFeature.Contrib.Providers.Flagd.E2e.Test\OpenFeature.Contrib.Providers.Flagd.E2e.Test.csproj", "{4A2C6E0F-8A23-454F-8019-AE3DD91AA193}"
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Contrib.Providers.Flagd.E2e.Common", "test\OpenFeature.Contrib.Providers.Flagd.E2e.Common\OpenFeature.Contrib.Providers.Flagd.E2e.Common.csproj", "{4A2C6E0F-8A23-454F-8019-AE3DD91AA193}"
3535
EndProject
3636
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFeature.Contrib.Providers.Flagd.E2e.RpcTest", "test\OpenFeature.Contrib.Providers.Flagd.E2e.RpcTest\OpenFeature.Contrib.Providers.Flagd.E2e.RpcTest.csproj", "{2ACD9150-A8F4-450E-B49A-C628895992BF}"
3737
EndProject

build/Common.prod.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<PropertyGroup>
12-
<TargetFrameworks>netstandard2.0;net462;net8.0</TargetFrameworks>
12+
<TargetFrameworks>netstandard2.0;net462;net8.0;net9.0</TargetFrameworks>
1313
<RepositoryType>git</RepositoryType>
1414
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
1515
<Description>OpenFeature is an open specification that provides a vendor-agnostic,
@@ -27,4 +27,4 @@
2727
<None Include="$(MSBuildThisFileDirectory)openfeature-icon.png" Pack="true" PackagePath="\" />
2828
</ItemGroup>
2929

30-
</Project>
30+
</Project>

build/Common.props

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
<Project>
2+
<PropertyGroup>
3+
<LangVersion>latest</LangVersion>
4+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
5+
<NuGetAudit>true</NuGetAudit>
6+
<NuGetAuditMode>all</NuGetAuditMode>
7+
<NuGetAuditLevel>low</NuGetAuditLevel>
8+
</PropertyGroup>
29

3-
<ItemGroup>
4-
<PackageReference Include="OpenFeature" Version="$(OpenFeatureVer)" />
5-
</ItemGroup>
10+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
11+
<DebugType>full</DebugType>
12+
<DebugSymbols>true</DebugSymbols>
13+
</PropertyGroup>
614

7-
<PropertyGroup>
8-
<LangVersion>latest</LangVersion>
9-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10-
<NuGetAudit>true</NuGetAudit>
11-
<NuGetAuditMode>all</NuGetAuditMode>
12-
<NuGetAuditLevel>low</NuGetAuditLevel>
13-
</PropertyGroup>
15+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
16+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
17+
</PropertyGroup>
1418

15-
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
16-
<DebugType>full</DebugType>
17-
<DebugSymbols>true</DebugSymbols>
18-
</PropertyGroup>
19-
20-
<PropertyGroup Condition="'$(Configuration)'=='Release'">
21-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
22-
</PropertyGroup>
23-
24-
<PropertyGroup Label="Package versions used in this repository">
25-
<!--
26-
Please sort alphabetically.
27-
Refer to https://docs.microsoft.com/nuget/concepts/package-versioning for semver syntax.
28-
-->
29-
<!-- 2.0-2.9999 -->
30-
<OpenFeatureVer>[2.0,3.0)</OpenFeatureVer>
31-
</PropertyGroup>
32-
33-
<ItemGroup Condition="'$(OS)' == 'Unix'">
34-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"
35-
PrivateAssets="all" />
36-
</ItemGroup>
19+
<ItemGroup Condition="'$(OS)' == 'Unix'">
20+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"
21+
PrivateAssets="all" />
22+
</ItemGroup>
3723
</Project>

build/Common.tests.props

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
<Project>
2-
<Import Project=".\Common.props" />
2+
<Import Project=".\Common.props" />
33

4-
<PropertyGroup>
5-
<IsPackable>false</IsPackable>
6-
<TargetFrameworks>net8.0</TargetFrameworks>
7-
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
8-
</PropertyGroup>
4+
<PropertyGroup>
5+
<IsPackable>false</IsPackable>
6+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
7+
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
8+
</PropertyGroup>
99

10-
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Test'))">
11-
<IsTestProject>true</IsTestProject>
12-
</PropertyGroup>
10+
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('Test'))">
11+
<IsTestProject>true</IsTestProject>
12+
</PropertyGroup>
1313

14-
<PropertyGroup>
15-
<NoWarn>$(NoWarn);CA2007</NoWarn>
16-
</PropertyGroup>
14+
<PropertyGroup>
15+
<NoWarn>$(NoWarn);CA2007</NoWarn>
16+
</PropertyGroup>
1717

18-
<ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
19-
<Content
20-
Include="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'DotnetSdkContrib.sln'))\build\xunit.runner.json">
21-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22-
</Content>
23-
</ItemGroup>
18+
<ItemGroup Condition="$(MSBuildProjectName.EndsWith('Test'))">
19+
<Content
20+
Include="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'DotnetSdkContrib.sln'))\build\xunit.runner.json">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</Content>
23+
</ItemGroup>
2424

25-
<ItemGroup>
26-
<PackageReference Include="AutoFixture" Version="$(AutoFixtureVer)" />
27-
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVer)">
28-
<PrivateAssets>all</PrivateAssets>
29-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
30-
</PackageReference>
31-
<PackageReference Include="coverlet.msbuild" Version="$(CoverletCollectorVer)">
32-
<PrivateAssets>all</PrivateAssets>
33-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34-
</PackageReference>
35-
<PackageReference Include="GitHubActionsTestLogger" Version="$(GitHubActionsTestLoggerVer)" />
36-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
37-
<PackageReference Include="NSubstitute" Version="$(NSubstituteVer)" />
38-
<PackageReference Include="xunit" Version="$(XUnitPkgVer)" />
39-
<PackageReference Include="xunit.runner.visualstudio"
40-
Version="$(XUnitRunnerVisualStudioPkgVer)">
41-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
42-
<PrivateAssets>all</PrivateAssets>
43-
</PackageReference>
25+
<ItemGroup>
26+
<PackageReference Include="AutoFixture" Version="$(AutoFixtureVer)" />
27+
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVer)">
28+
<PrivateAssets>all</PrivateAssets>
29+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
30+
</PackageReference>
31+
<PackageReference Include="coverlet.msbuild" Version="$(CoverletCollectorVer)">
32+
<PrivateAssets>all</PrivateAssets>
33+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34+
</PackageReference>
35+
<PackageReference Include="GitHubActionsTestLogger" Version="$(GitHubActionsTestLoggerVer)" />
36+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
37+
<PackageReference Include="NSubstitute" Version="$(NSubstituteVer)" />
38+
<PackageReference Include="xunit" Version="$(XUnitPkgVer)" />
39+
<PackageReference Include="xunit.runner.visualstudio"
40+
Version="$(XUnitRunnerVisualStudioPkgVer)">
41+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
42+
<PrivateAssets>all</PrivateAssets>
43+
</PackageReference>
4444

45-
<!-- Fare and System.Text.RegularExpressions are referenced directly to avoid indirect
45+
<!-- Fare and System.Text.RegularExpressions are referenced directly to avoid indirect
4646
vulnerable packages from AutoFixture -->
47-
<PackageReference Include="Fare" Version="$(FareVer)" />
48-
<PackageReference Include="System.Text.RegularExpressions"
49-
Version="$(SystemTextRegularExpressionsVer)" />
50-
</ItemGroup>
47+
<PackageReference Include="Fare" Version="$(FareVer)" />
48+
<PackageReference Include="System.Text.RegularExpressions"
49+
Version="$(SystemTextRegularExpressionsVer)" />
50+
</ItemGroup>
5151

52-
<PropertyGroup Label="Package versions used in this repository">
53-
<!--
52+
<PropertyGroup Label="Package versions used in this repository">
53+
<!--
5454
Please sort alphabetically.
5555
Refer to https://docs.microsoft.com/nuget/concepts/package-versioning for semver syntax.
5656
-->
57-
<AutoFixtureVer>[4.18.1]</AutoFixtureVer>
58-
<CoverletCollectorVer>[3.1.2]</CoverletCollectorVer>
59-
<FareVer>[2.2.1]</FareVer>
60-
<GitHubActionsTestLoggerVer>[2.3.3]</GitHubActionsTestLoggerVer>
61-
<MicrosoftNETTestSdkPkgVer>[17.13.0]</MicrosoftNETTestSdkPkgVer>
62-
<NSubstituteVer>[5.0.0]</NSubstituteVer>
63-
<SystemTextRegularExpressionsVer>[4.3.1]</SystemTextRegularExpressionsVer>
64-
<XUnitRunnerVisualStudioPkgVer>[2.8.2,3.0)</XUnitRunnerVisualStudioPkgVer>
65-
<XUnitPkgVer>[2.9.3,3.0)</XUnitPkgVer>
66-
</PropertyGroup>
57+
<AutoFixtureVer>[4.18.1]</AutoFixtureVer>
58+
<CoverletCollectorVer>[3.1.2]</CoverletCollectorVer>
59+
<FareVer>[2.2.1]</FareVer>
60+
<GitHubActionsTestLoggerVer>[2.3.3]</GitHubActionsTestLoggerVer>
61+
<MicrosoftNETTestSdkPkgVer>[17.13.0]</MicrosoftNETTestSdkPkgVer>
62+
<NSubstituteVer>[5.0.0]</NSubstituteVer>
63+
<SystemTextRegularExpressionsVer>[4.3.1]</SystemTextRegularExpressionsVer>
64+
<XUnitRunnerVisualStudioPkgVer>[2.8.2,3.0)</XUnitRunnerVisualStudioPkgVer>
65+
<XUnitPkgVer>[2.9.3,3.0)</XUnitPkgVer>
66+
</PropertyGroup>
6767
</Project>

renovate.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": [
4-
"github>open-feature/community-tooling"
5-
]
6-
}
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"github>open-feature/community-tooling"
5+
],
6+
"dependencyDashboardApproval": true,
7+
"recreateWhen": "never"
8+
}

src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="OpenTelemetry.Api" Version="1.9.0" />
15+
<PackageReference Include="OpenFeature" Version="[2.0,3.0)" />
1516
</ItemGroup>
1617

17-
</Project>
18+
</Project>

src/OpenFeature.Contrib.Providers.ConfigCat/OpenFeature.Contrib.Providers.ConfigCat.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
</AssemblyAttribute>
1717
</ItemGroup>
1818
<ItemGroup>
19-
<PackageReference Include="ConfigCat.Client" Version="9.3.2"/>
19+
<PackageReference Include="ConfigCat.Client" Version="9.3.2" />
20+
<PackageReference Include="OpenFeature" Version="[2.0,3.0)" />
2021
</ItemGroup>
21-
</Project>
22+
</Project>
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<PackageId>OpenFeature.Contrib.Providers.EnvVar</PackageId>
5-
<VersionNumber>0.0.2</VersionNumber> <!--x-release-please-version -->
6-
<VersionPrefix>$(VersionNumber)</VersionPrefix>
7-
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
8-
<FileVersion>$(VersionNumber)</FileVersion>
9-
<Description>Environment Variable Provider for .NET</Description>
10-
<Authors>Octopus Deploy</Authors>
11-
</PropertyGroup>
3+
<PropertyGroup>
4+
<PackageId>OpenFeature.Contrib.Providers.EnvVar</PackageId>
5+
<VersionNumber>0.0.2</VersionNumber> <!--x-release-please-version -->
6+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
7+
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
8+
<FileVersion>$(VersionNumber)</FileVersion>
9+
<Description>Environment Variable Provider for .NET</Description>
10+
<Authors>Octopus Deploy</Authors>
11+
</PropertyGroup>
1212

13-
</Project>
13+
<ItemGroup>
14+
<PackageReference Include="OpenFeature" Version="[2.0,3.0)" />
15+
</ItemGroup>
16+
17+
</Project>

src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
<VersionSuffix>preview</VersionSuffix>
88
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
99
<FileVersion>$(VersionNumber)</FileVersion>
10-
<Description>An OpenFeature Provider built on top of the standard Microsoft FeatureManagement Library</Description>
10+
<Description>An OpenFeature Provider built on top of the standard Microsoft FeatureManagement
11+
Library</Description>
1112
<Authors>Eric Pattison</Authors>
1213
</PropertyGroup>
1314

1415
<ItemGroup>
1516
<PackageReference Include="Microsoft.FeatureManagement" Version="4.0.0" />
17+
<PackageReference Include="OpenFeature" Version="[2.0,3.0)" />
1618
</ItemGroup>
1719

18-
</Project>
20+
</Project>

src/OpenFeature.Contrib.Providers.Flagd/FlagdConfig.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ public string SourceSelector
162162

163163
internal FlagdConfig()
164164
{
165-
_host = Environment.GetEnvironmentVariable(EnvVarHost) ?? "localhost";
165+
_host = string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(EnvVarHost)) ? "localhost" : Environment.GetEnvironmentVariable(EnvVarHost);
166166
_port = int.TryParse(Environment.GetEnvironmentVariable(EnvVarPort), out var port) ? port : 8013;
167-
_useTLS = bool.Parse(Environment.GetEnvironmentVariable(EnvVarTLS) ?? "false");
167+
_useTLS = bool.TryParse(Environment.GetEnvironmentVariable(EnvVarTLS), out var useTLS) ? useTLS : false;
168168
_cert = Environment.GetEnvironmentVariable(EnvCertPart) ?? "";
169169
_socketPath = Environment.GetEnvironmentVariable(EnvVarSocketPath) ?? "";
170170
_sourceSelector = Environment.GetEnvironmentVariable(EnvVarSourceSelector) ?? "";
@@ -173,8 +173,8 @@ internal FlagdConfig()
173173
if (string.Equals(cacheStr, LruCacheValue, StringComparison.OrdinalIgnoreCase))
174174
{
175175
_cache = true;
176-
_maxCacheSize = int.Parse(Environment.GetEnvironmentVariable(EnvVarMaxCacheSize) ?? $"{CacheSizeDefault}");
177-
_maxEventStreamRetries = int.Parse(Environment.GetEnvironmentVariable(EnvVarMaxEventStreamRetries) ?? "3");
176+
_maxCacheSize = int.TryParse(Environment.GetEnvironmentVariable(EnvVarMaxCacheSize), out var maxCacheSize) ? maxCacheSize : CacheSizeDefault;
177+
_maxEventStreamRetries = int.TryParse(Environment.GetEnvironmentVariable(EnvVarMaxEventStreamRetries), out var maxEventStreamRetries) ? maxEventStreamRetries : 3;
178178
}
179179

180180
var resolverTypeStr = Environment.GetEnvironmentVariable(EnvVarResolverType) ?? "RPC";
@@ -200,8 +200,8 @@ internal FlagdConfig(Uri url)
200200
if (string.Equals(cacheStr, LruCacheValue, StringComparison.OrdinalIgnoreCase))
201201
{
202202
_cache = true;
203-
_maxCacheSize = int.Parse(Environment.GetEnvironmentVariable(EnvVarMaxCacheSize) ?? $"{CacheSizeDefault}");
204-
_maxEventStreamRetries = int.Parse(Environment.GetEnvironmentVariable(EnvVarMaxEventStreamRetries) ?? "3");
203+
_maxCacheSize = int.TryParse(Environment.GetEnvironmentVariable(EnvVarMaxCacheSize), out var maxCacheSize) ? maxCacheSize : CacheSizeDefault;
204+
_maxEventStreamRetries = int.TryParse(Environment.GetEnvironmentVariable(EnvVarMaxEventStreamRetries), out var maxEventStreamRetries) ? maxEventStreamRetries : 3;
205205
}
206206

207207
var resolverTypeStr = Environment.GetEnvironmentVariable(EnvVarResolverType) ?? "RPC";

src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Description>flagd provider for .NET</Description>
1010
<Authors>Todd Baert</Authors>
1111
</PropertyGroup>
12-
12+
1313
<ItemGroup>
1414
<!-- make the internal methods visble to our test project -->
1515
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
@@ -20,7 +20,8 @@
2020
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="8.0.2" />
2121
</ItemGroup>
2222
<ItemGroup>
23-
<!-- The schema.proto file referenced here will be used to automatically generate the Grpc client when executing 'dotnet build' -->
23+
<!-- The schema.proto file referenced here will be used to automatically generate the Grpc
24+
client when executing 'dotnet build' -->
2425
<!-- The generated files will be placed in ./obj/Debug/netstandard2.0/Protos -->
2526
<PackageReference Include="JsonLogic" Version="5.4.0" />
2627
<PackageReference Include="murmurhash" Version="1.0.3" />
@@ -33,6 +34,8 @@
3334
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3435
<PrivateAssets>all</PrivateAssets>
3536
</PackageReference>
36-
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
37+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"
38+
Condition="'$(TargetFramework)' == 'netstandard2.0'" />
39+
<PackageReference Include="OpenFeature" Version="[2.0,3.0)" />
3740
</ItemGroup>
38-
</Project>
41+
</Project>

src/OpenFeature.Contrib.Providers.Flagd/Resolver/InProcess/InProcessResolver.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
#if NET462_OR_GREATER
88
using System.Linq;
99
using System.Net.Security;
10-
#endif
1110
using System.Security.Cryptography.X509Certificates;
11+
#endif
1212
using Grpc.Net.Client;
1313
#if NET8_0_OR_GREATER
14+
using System.Security.Cryptography.X509Certificates;
1415
using System.Net.Sockets; // needed for unix sockets
1516
#endif
1617
using System.Threading;
1718
using Grpc.Core;
1819
using Value = OpenFeature.Model.Value;
1920
using System.Threading.Channels;
2021
using OpenFeature.Constant;
22+
using OpenFeature.Contrib.Providers.Flagd.Utils;
2123

2224
namespace OpenFeature.Contrib.Providers.Flagd.Resolver.InProcess;
2325

@@ -190,8 +192,9 @@ private T BuildClient<T>(FlagdConfig config, Func<GrpcChannel, T> constructorFun
190192
{
191193
if (File.Exists(config.CertificatePath))
192194
{
193-
X509Certificate2 certificate = new X509Certificate2(config.CertificatePath);
194-
#if NET5_0_OR_GREATER
195+
var certificate = CertificateLoader.LoadCertificate(config.CertificatePath);
196+
197+
#if NET8_0_OR_GREATER
195198
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, _) => {
196199
// the the custom cert to the chain, Build returns a bool if valid.
197200
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
@@ -269,7 +272,7 @@ private FlagSyncService.FlagSyncServiceClient BuildClientForPlatform(FlagdConfig
269272
{
270273
if (File.Exists(config.CertificatePath))
271274
{
272-
X509Certificate2 certificate = new X509Certificate2(config.CertificatePath);
275+
var certificate = CertificateLoader.LoadCertificate(config.CertificatePath);
273276
#if NET5_0_OR_GREATER
274277
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, _) => {
275278
// the the custom cert to the chain, Build returns a bool if valid.

0 commit comments

Comments
 (0)