繁体   English   中英

服务器错误:请求已中止:无法创建SSL / TLS安全通道

[英]Server Error: The request was aborted: Could not create SSL/TLS secure channel

我收到错误消息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

没有任何特定的原因导致该代码在Windows 2012上失败,TLS可用并默认打开(我在一些新的2012R2盒子上测试了您的代码示例,因为我很偏执:)。

这意味着您的特定服务器的某些配置正在阻止使用TLS 1.2的连接。 检查以下内容:

  • 在注册表中,检查HKLM\\SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHANNEL\\Protocols SSL 2.0以外的协议是否被禁用(甚至提到)?
  • 在服务器上的事件日志中,连接事件失败后是否有任何Schannel事件?
  • 在服务器上,使用浏览器打开https://cloudfare.com 右键单击属性(假设为IE),它说的是TLS 1.2, AES with 128 bit encryption (High)吗? 如果没有,浏览器决定使用其他协议,因为客户端系统上不支持TLS 1.2。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM