I deployed a Kubernetes cluster in Microsoft Azure and would like to call some of the REST APIs from .Net Core C # using https. Certificates used when deploying a cluster to a non-trusted CA. When I run this program on a Mac, I get the following error: "System.Net.Http.CurlException: Peer certificate cannot be authenticated with these CA certificates"
On Windows, I can set my own ServerCertificateValidationCallback to ignore the error:
WinHttpHandler winHttpHandler = new WinHttpHandler();
winHttpHandler.ServerCertificateValidationCallback = ValidateServerCertificate;
public static bool ValidateServerCertificate(
HttpRequestMessage request,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}
But this is not supported in .Net Core on platforms other than Windows.
How to ignore the error on other platforms?