环境:控制台应用程序,C# Core 3.1,VS 2019
我正在执行以下行:
var response = await client.SendAsync(request).ConfigureAwait(false);
我收到以下错误:
{"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 ...
做了一些谷歌搜索并发现了这个:
https://github.com/dotnet/runtime/issues/28189
所以我添加了
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
就在上面那行之前。仍然收到错误。
在执行行之前我有一堆代码:
httpClientHandler = new HttpClientHandler
{
SslProtocols = SslProtocols.Tls12
};
添加用于添加证书、标头、内容类型等的代码。不确定到底是什么导致了错误。有任何想法吗?
Thanks,
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)