Asp.net Mono TLS错误TLSV1\u警报\u协议\u版本

Asp.net Mono TLS错误TLSV1\u警报\u协议\u版本,asp.net,ssl,mono,Asp.net,Ssl,Mono,我有一个执行HTTP请求的ASP.NET应用程序,它本周开始抛出此错误 2019-11-15 16:05:35,833 Error Line:0 121156 Thread: Thread Pool Worker Level: ERROR Logger: Joystick.WebServices.Infrastructure.Log4NetLogger Message: System.Net.WebException: Error: SecureChannelFailure (Authentic

我有一个执行HTTP请求的ASP.NET应用程序,它本周开始抛出此错误

2019-11-15 16:05:35,833 Error Line:0 121156 Thread: Thread Pool Worker Level: ERROR Logger: Joystick.WebServices.Infrastructure.Log4NetLogger Message: System.Net.WebException: Error: SecureChannelFailure (Authentication failed, see inner exception.) ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000042e:SSL routines:OPENSSL_internal:TLSV1_ALERT_PROTOCOL_VERSION
  at /build/mono-6.4.0.198/external/boringssl/ssl/tls_record.c:462
  at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00048] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
   --- End of inner exception stack trace ---
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00262] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at Mono.Net.Security.MonoTlsStream.CreateStream (System.Net.WebConnectionTunnel tunnel, System.Threading.CancellationToken cancellationToken) [0x00176] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at System.Net.WebConnection.CreateStream (System.Net.WebOperation operation, System.Boolean reused, System.Threading.CancellationToken cancellationToken) [0x001ba] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
   --- End of inner exception stack trace ---
  at System.Net.WebConnection.CreateStream (System.Net.WebOperation operation, System.Boolean reused, System.Threading.CancellationToken cancellationToken) [0x0021a] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at System.Net.WebConnection.InitConnection (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) [0x00141] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at System.Net.WebOperation.Run () [0x0009a] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at System.Net.WebCompletionSource`1[T].WaitForCompletion () [0x00094] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at System.Net.HttpWebRequest.GetRequestStream () [0x00016] in <2703bbaa0a6e4686b6033c2dddb1a363>:0 
  at Joystick.WebServices.Handlers.Nap.NapWebHandler.SendRequest (Joystick.Dto.System.NapCheckDto patient) [0x00121] in <7c3b0be4b3414e1c95351062f5cf9947>:0 
  at Joystick.WebServices.Handlers.Nap.NapWebHandler.ProcessMessage (Joystick.Dto.System.NapCheckDto req) [0x00027] in <7c3b0be4b3414e1c95351062f5cf9947>:0 



没有任何帮助。

正是该站点,他们正在更换主机,并且有一段时间存在较旧的基础设施,导致了此问题。

使用TLS 1.2,无论您连接的是什么,都不再支持过时的TLS 1.0如何?这就是我不知道如何让ti使用更高版本的TLS的要点。您正在设置env。要使用legacy,请不要这样做。

Environment.SetEnvironmentVariable("MONO_TLS_PROVIDER", "legacy", EnvironmentVariableTarget.User);
AppContext.SetSwitch("Switch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithms", true);
AppContext.SetSwitch("Switch.System.Security.Cryptography.Pkcs.UseInsecureHashAlgorithms", true);
AppContext.SetSwitch("Switch.System.Net.DontEnableSystemDefaultTlsVersions", true);