Skip to content

Commit 915662c

Browse files
authored
.Net: Fix PlatformNotSupportedException from HttpClientProvider (#6323)
On older .NET Frameworks, CheckCertificateRevocationList may not be supported. https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler.checkcertificaterevocationlist?view=net-8.0#exceptions
1 parent e17e05a commit 915662c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

dotnet/src/InternalUtilities/src/Http/HttpClientProvider.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ private static SocketsHttpHandler CreateHandler()
9191
#else
9292
private static HttpClientHandler CreateHandler()
9393
{
94-
return new HttpClientHandler()
94+
var handler = new HttpClientHandler();
95+
try
9596
{
96-
// Check cert revocation
97-
CheckCertificateRevocationList = true,
98-
};
97+
handler.CheckCertificateRevocationList = true;
98+
}
99+
catch (PlatformNotSupportedException) { } // not supported on older frameworks
100+
return handler;
99101
}
100102
#endif
101103
}

0 commit comments

Comments
 (0)