In C#, when using HttpClient, how can I connect to the https server that is using either self-signed certificate (for testing) or a custom CA that is not part of the machine's trust-store? Note that I m not needing client certificates, only need HttpClient to validate the server certificate that is not signed by one of the trusted root CA on the machine. I know that i could just add the self-signed certificate or the CA to the local trust-store on the machine, but let's say I want to avoid doing this. What i need is basically to supply extra root CA to the running application.
There are quite simple ways to do this in other languages as I know:
In java, using "javax.net.ssl.trustStore" system property.
In Node.js, using NODE_EXTRA_CA_CERT environment variable.
But I couldn't find anything like this for .Net so far. Is there a simple way like the above?