Skip to content

HttpClientHandler.DangerousAcceptAnyServerCertificateValidator backing field is not being trimmed #1270

@eerhardt

Description

@eerhardt

See the code here:

https://github.com/dotnet/runtime/blob/bd6cbe3642f51d70839912a6a666e5de747ad581/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs#L225

public static Func<HttpRequestMessage, X509Certificate2?, X509Chain?, SslPolicyErrors, bool> DangerousAcceptAnyServerCertificateValidator { get; } = delegate { return true; };

When this public property is not used, the public property is getting trimmed away. However, the private backing field is not getting trimmed. This is causing X509Certificate2 and X509Chain (just the empty classes) to be preserved as well.

image

The linker should be able to see there are no callers of this backing field and remove it.

cc @vitek-karas @MichalStrehovsky @marek-safar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions