Env: Console App, C# Core 3.1, VS 2019
I'm executing the following line:
var response = await client.SendAsync(request).ConfigureAwait(false);
I'm getting the following error:
{"The SSL connection could not be established, see inner exception."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233087
HelpLink: null
InnerException: {"Authentication failed, see inner exception."}
Message: "The SSL connection could not be established, see inner exception."
Source: "System.Net.Http"
StackTrace: " at System.Net.Http.ConnectHelper.<EstablishSslConnectionAsyncCore>d__4.MoveNext()\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at ...
Did some googling and found this:
https://github.com/dotnet/runtime/issues/28189
So I added
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
right before the above line. Still getting the error.
I have a bunch of code prior to the executed line:
httpClientHandler = new HttpClientHandler
{
SslProtocols = SslProtocols.Tls12
};
Plus code to add the certificate, header, content-type, etc. Not sure what is actually causing the error. Any ideas?
Thanks,
httpClientHandler.ServerCertificateCustomValidationCallback = (sender,certificate,chain,sslPolicyError)=>{return true;};
. This gives me a new error:System.Net.Http.HttpRequestException: An error occurred while sending the request. --->System.Net.Http.WinHttpException(80072F8F,12175):Error12175 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A security error occurred'. at System.Threading.Tasks.RendezvousAwaitable`1.GetResult() at System.Net.Http.WinHttpHandler.StartRequestAsync(WinHttpRequestState state) --- End of inner exception stack trace ---
– Lictor