Skip to content

Commit

Permalink
[Android][iOS] Enable HttpClientHandler.DangerousAcceptAnyServerCerti…
Browse files Browse the repository at this point in the history
…ficateValidator when using native handlers (dotnet#73763)

The static `HttpClientHandler.DangerousAcceptAnyServerCertificateValidator` getter throws PNSE when the native HTTP handler is enabled because Xamarin.Android's `AndroidMessageHandler` and Xamarin.iOS `NSUrlSessionHandler` didn't use to have support for the `ServerCertificateCustomValidationCallback`.

We already implemented the Android part in .NET 6 and support in the iOS implementation is WIP and we should be able to implement it in time for .NET 7. IMO it's safe to remove the exception in the getter in .NET 7.

Closes dotnet#68898
  • Loading branch information
simonrozsival authored Aug 11, 2022
1 parent 14be2a0 commit d2c991e
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,9 @@ protected internal override Task<HttpResponseMessage> SendAsync(HttpRequestMessa
{
get
{
if (IsNativeHandlerEnabled)
{
throw new PlatformNotSupportedException();
}
else
{
return Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ??
Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
s_dangerousAcceptAnyServerCertificateValidator;
}
return Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ??
Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
s_dangerousAcceptAnyServerCertificateValidator;
}
}

Expand Down

0 comments on commit d2c991e

Please sign in to comment.