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

Prevent server certificate callback runtime exception #2213

Merged
merged 3 commits into from
Nov 10, 2023
Merged

Conversation

stevejgordon
Copy link
Contributor

@stevejgordon stevejgordon commented Nov 3, 2023

On .NET Full framework <4.7.2, HttpClientHandler.ServerCertificateCustomValidationCallback is not available. Due to dependency binding issues introduced with .NET standard, the incorrect System.Net.Http package may be resolved and lead to exceptions at runtime.

This fix prevents calling this API on net462 targets which includes any .NET Framework version < .NET 4.7.2.

This introduces the net472 target so that we can resume using this API from that version, where it was included in the box.

Fixes #2212

gregkalapos
gregkalapos previously approved these changes Nov 3, 2023
Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

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

Changes LGTM.

We have related docs here: https://github.com/elastic/apm-agent-dotnet/blob/main/docs/configuration.asciidoc

With this PR, VerifyServerCert and ServerCert won't work on net462 anymore - which was problematic anyways, so all intentional.

Do we maybe want to add a note about net462 versions older than .NET 4.7.2 to the doc?

On .NET Full framework <4.7.2, HttpClientHandler.ServerCertificateCustomValidationCallback is not available. Due to dependency binding issues introduced with netstandard,
the incorrect System.Net.Http package may be resolved and lead to exceptions at runtime.

This fix prevents calling this API on net462 targets which includes any .NET Framework version < .NET 4.7.2.

This introduces the net472 target so that we can resume using this API from that version, where it was included in the box.
@stevejgordon stevejgordon merged commit 7933659 into main Nov 10, 2023
12 checks passed
@stevejgordon stevejgordon deleted the bug/2212 branch November 10, 2023 08:40
github-actions bot pushed a commit that referenced this pull request Nov 21, 2023
* Prevent server certificate callback runtime exception

On .NET Full framework <4.7.2, HttpClientHandler.ServerCertificateCustomValidationCallback is not available. Due to dependency binding issues introduced with netstandard,
the incorrect System.Net.Http package may be resolved and lead to exceptions at runtime.

This fix prevents calling this API on net462 targets which includes any .NET Framework version < .NET 4.7.2.

This introduces the net472 target so that we can resume using this API from that version, where it was included in the box.

* Update documentation

* Tweak docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] MissingMethodException: set_ServerCertificateCustomValidationCallback
2 participants