Sample application to showcase how to add trusted root authorities in .NET via code
The pages will make a request to a server with an untrusted root (https://untrusted-root.badssl.com), hash that content and show it on the page.
Here we set up the ServicePointManager which some TLS APIs use
This uses WebRequest (deprecated) and works out of the box from the ServicePointManager set up done on Program.cs
This uses HttpClient and will fail because this API does not use ServicePointManager
This uses HttpClient and will succeed since it is configured to use HttpClientHandler to override the default behavior
This version uses HttpClient with dependency injection which is set up on Program.cs . With this approach you do not have to set up HttpClient on every use.