Commit a5f42d7f authored by Honfika's avatar Honfika

server connection hack: try to use tls1.0 when tls 1.2 fails

parent c7e34cc7
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Authentication;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -266,6 +268,10 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -266,6 +268,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
SslApplicationProtocol negotiatedApplicationProtocol = default; SslApplicationProtocol negotiatedApplicationProtocol = default;
bool retry = true;
var enabledSslProtocols = proxyServer.SupportedSslProtocols;
retry:
try try
{ {
tcpClient = new TcpClient(upStreamEndPoint) tcpClient = new TcpClient(upStreamEndPoint)
...@@ -365,7 +371,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -365,7 +371,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
ApplicationProtocols = applicationProtocols, ApplicationProtocols = applicationProtocols,
TargetHost = remoteHostName, TargetHost = remoteHostName,
ClientCertificates = null, ClientCertificates = null,
EnabledSslProtocols = proxyServer.SupportedSslProtocols, EnabledSslProtocols = enabledSslProtocols,
CertificateRevocationCheckMode = proxyServer.CheckCertificateRevocation CertificateRevocationCheckMode = proxyServer.CheckCertificateRevocation
}; };
await sslStream.AuthenticateAsClientAsync(options, cancellationToken); await sslStream.AuthenticateAsClientAsync(options, cancellationToken);
...@@ -380,6 +386,12 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -380,6 +386,12 @@ namespace Titanium.Web.Proxy.Network.Tcp
} }
} }
catch (IOException ex) when (ex.HResult == unchecked((int)0x80131620) && retry)
{
enabledSslProtocols = SslProtocols.Tls;
retry = false;
goto retry;
}
catch (Exception) catch (Exception)
{ {
stream?.Dispose(); stream?.Dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment