.NET请求已中止:无法创建SSL/TLS安全通道

本文关键字:SSL 创建 TLS 通道 安全 请求 NET | 更新日期: 2023-09-27 18:28:30

对于这个问题,我已经尝试了所有可能的解决方案,但似乎都不起作用。以下是提取的跟踪日志(一个用于尝试与Paypal对话,另一个用于试图与GetSentry对话):

System.Net Information: 0 : [10776] SecureChannel#49633458::.ctor(hostname=svcs.sandbox.paypal.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [10776] SecureChannel#49633458 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [10776] Using the cached credential handle.
System.Net Information: 0 : [10776] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = svcs.sandbox.paypal.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [10776] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=58, returned code=ContinueNeeded).
System.Net Information: 0 : [10776] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 69e8d930e0:cc64028eb0, targetName = svcs.sandbox.paypal.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [10776] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net Error: 0 : [10776] Exception in HttpWebRequest#2657604:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [10776] Exception in HttpWebRequest#2657604::GetResponse - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Information: 0 : [10776] SecureChannel#39602548::.ctor(hostname=app.getsentry.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [10776] SecureChannel#39602548 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [10776] Using the cached credential handle.
System.Net Information: 0 : [10776] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = app.getsentry.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [10776] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=58, returned code=ContinueNeeded).
System.Net Information: 0 : [10776] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 69e8d930e0:cc64029510, targetName = app.getsentry.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [10776] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net Error: 0 : [10776] Exception in HttpWebRequest#49716141:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [10776] Exception in HttpWebRequest#49716141::GetResponse - The request was aborted: Could not create SSL/TLS secure channel..

我试过

ServicePointManager.ServerCertificateValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => true;

以及(Application_Start in Global.asax.cs)

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

似乎没有什么帮助。这是在MVC应用程序中的Windows 8.1 Pro盒子上。

.NET请求已中止:无法创建SSL/TLS安全通道

看起来我使用的SharpRaven库版本强制ServicePointManager.SecurityProtocol到SSL3,中断了任何后续调用。新的库版本没有做到这一点,但在执行调用之前,我仍然明确地将其设置为TLS,只是为了更好地衡量。