You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 1, 2025. It is now read-only.
I use it at local has been success. when i use on the server it's not work.
throw exception
Unhandled Exception: System.AggregateException: One or more errors occurred. (The SSL connection could not be established, see inner exception.) ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
I use flowing code make it right
private readonly HttpClient _client;
public WebClient(Environment environment)
{
HttpClientHandler httpClientHandler = new HttpClientHandler();
httpClientHandler.ServerCertificateCustomValidationCallback += ValidateCert;
_client = new HttpClient(httpClientHandler) { BaseAddress = new Uri($"{environment.BaseUrl}") };
_client.DefaultRequestHeaders.Add("User-Agent", "stuart-client-csharp/1.3.1");
}
private bool ValidateCert(HttpRequestMessage message, X509Certificate2 x509Certificate2, X509Chain x509Chain, SslPolicyErrors errors)
{
if (x509Certificate2 != null && x509Chain != null)
{
if (x509Certificate2.Verify())
{
return x509Chain.Build(x509Certificate2);
}
}
return false;
}
but I don't think that's right. may be contais onther good ideas.