Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add System.Net.Http ServerCertificateCustomValidationCallback ILLink Suppression #58456

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@
<property name="Target">M:System.Net.Http.HttpClientHandler.SetMaxAutomaticRedirections(System.Int32)</property>
<property name="Justification">The Xamarin.iOS and Mono.Android libraries are not present when running the trimmer analysis during our build. A consuming application will get a warning if these libraries aren't present when trimming the full app.</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveisok @mdh1418 - this is a pretty massive xml suppression file. It may make sense to make it AnyMobile specific and only use it when building for AnyMobile targets. That way we don't inadvertently suppress warnings when we shouldn't be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdh1418 Can you do a follow up PR w/ Eric's suggestion?

<argument>ILLink</argument>
<argument>IL2035</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Net.Http.HttpClientHandler.GetServerCertificateCustomValidationCallback</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2035</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Net.Http.HttpClientHandler.SetServerCertificateCustomValidationCallback(System.Func{System.Net.Http.HttpRequestMessage,System.Security.Cryptography.X509Certificates.X509Certificate2,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors,System.Boolean})</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2035</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public partial class HttpClientHandler : HttpMessageHandler
[DynamicDependency("get_ClientCertificates", NativeHandlerType, AssemblyName)]
private X509CertificateCollection GetClientCertificates() => (X509CertificateCollection)InvokeNativeHandlerMethod("get_ClientCertificates");

[DynamicDependency("get_ServerCertificateCustomValidationCallback", NativeHandlerType, AssemblyName)]
private Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> GetServerCertificateCustomValidationCallback() => (Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>)InvokeNativeHandlerMethod("get_ServerCertificateCustomValidationCallback");

[DynamicDependency("set_ServerCertificateCustomValidationCallback", NativeHandlerType, AssemblyName)]
private void SetServerCertificateCustomValidationCallback(Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool>? value) => InvokeNativeHandlerMethod("set_ServerCertificateCustomValidationCallback", value);

[DynamicDependency("get_CheckCertificateRevocationList", NativeHandlerType, AssemblyName)]
private bool GetCheckCertificateRevocationList() => (bool)InvokeNativeHandlerMethod("get_CheckCertificateRevocationList");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public X509CertificateCollection ClientCertificates
{
if (IsNativeHandlerEnabled)
{
throw new PlatformNotSupportedException();
return GetServerCertificateCustomValidationCallback();
}
else
{
Expand All @@ -437,7 +437,7 @@ public X509CertificateCollection ClientCertificates
{
if (IsNativeHandlerEnabled)
{
throw new PlatformNotSupportedException();
SetServerCertificateCustomValidationCallback(value);
}
else
{
Expand Down