我有错误
The request was aborted: Could not create SSL/TLS secure channel.
向cloudflare上的https端点发出请求时。
代码:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var wc = new WebClient();
var json = wc.DownloadString("https://cloudflare.com");
Console.Write(json);
这是Stack上的一个常见问题,将ServicePoint设置为TLS12可以解决此问题。这在本地帮我解决了问题。然而,每当我将代码升级到服务器时,错误就会再次出现(我肯定我的代码更改已经应用)。如果我删除https并使用http,它就可以正常工作。
经过无数次搜索,我找到了这个知识库:
https://support.microsoft.com/en-us/kb/3109853
我在Server1上安装了它,但它没有解决问题。
有人知道还有什么可以尝试吗?服务器环境一定是造成这种情况的原因。它是.Net修复程序/安全更新的最新版本。
[WebException: The request was aborted: Could not create SSL/TLS secure channel.]
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +823
System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) +84
[HttpRequestException: An error occurred while sending the request.]
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +66
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +30
TrackerBase.Controllers.<Verify>d__0.MoveNext() +535
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +66
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +30
lambda_method(Closure , Task ) +40
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +76
System.Web.Mvc.Async.<>c__DisplayClass3f.<BeginInvokeAsynchronousActionMethod>b__3e(IAsyncResult asyncResult) +21
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +80
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +386
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +30
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +900
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +1299
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +22
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +43
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +22
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +18