Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

In transparent proxy DecryptSsl is not working #804

Closed
akshata15 opened this issue Oct 7, 2020 · 3 comments
Closed

In transparent proxy DecryptSsl is not working #804

akshata15 opened this issue Oct 7, 2020 · 3 comments

Comments

@akshata15
Copy link

akshata15 commented Oct 7, 2020

I am using transparent proxy of TitaniumWebProxy to work with linux environment. here I am trying to bypass some of the URLs using DecryptSsl=false in transparentProxyEndPoint.BeforeSslAuthenticate event. But the url is getting blocked, it shows the message "Site can't be reached".

Handling event using:
transparentProxyEndPoint.BeforeSslAuthenticate += OnBeforeSslAuthenticate;

Event Handler:

private async Task OnBeforeSslAuthenticate(object sender, BeforeSslAuthenticateEventArgs e)
    {
        try
        {   
            string hostname = e.SniHostName;             
            if (hostname.Contains("zoom.us")|| hostname.Contains("zoom.in"))
            {
                e.DecryptSsl = false;                    
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("OnBeforeSslAuthenticate() => :: " + ex);
        }
    }

by adding Some logs i found exception , giving stacktrace bellow.

Exception => Error occured in whilst handling the client:: System.Exception: Could not establish connection to www.zoom.us
   at Titanium.Web.Proxy.Network.Tcp.TcpConnectionFactory.createServerConnection(String remoteHostName, Int32 remotePort, Version httpVersion, Boolean isHttps, SslProtocols sslProtocol, List`1 applicationProtocols, Boolean isConnect, P>
   at Titanium.Web.Proxy.Network.Tcp.TcpConnectionFactory.GetServerConnection(ProxyServer proxyServer, String remoteHostName, Int32 remotePort, Version httpVersion, Boolean isHttps, List`1 applicationProtocols, Boolean isConnect, Sessi>
   at Titanium.Web.Proxy.ProxyServer.handleClient(TransparentBaseProxyEndPoint endPoint, TcpClientConnection clientConnection, Int32 port, CancellationTokenSource cancellationTokenSource, CancellationToken cancellationToken)

getting null value in "createServerConnection()".

if (tcpServerSocket == null)
               {
                   if (sessionArgs != null && proxyServer.CustomUpStreamProxyFailureFunc != null)
                   {
                       var newUpstreamProxy = await proxyServer.CustomUpStreamProxyFailureFunc(sessionArgs);
                       if (newUpstreamProxy != null)
                       {
                           sessionArgs.CustomUpStreamProxyUsed = newUpstreamProxy;
                           sessionArgs.TimeLine["Retrying Upstream Proxy Connection"] = DateTime.UtcNow;
                           return await createServerConnection(remoteHostName, remotePort, httpVersion, isHttps, sslProtocol, applicationProtocols, isConnect, proxyServer, sessionArgs, upStreamEndPoint, externalProxy, cacheKey, cancellationToken);
                       }
                   }

                   throw new Exception($"Could not establish connection to {hostname}", lastException);
               }

this gives null value
public Func<SessionEventArgsBase, Task<IExternalProxy?>>? CustomUpStreamProxyFailureFunc { get; set; }

Please help me out.

@santosh05121993
Copy link

Is there any solution or workaround for this issue ?

@justcoding121
Copy link
Owner

justcoding121 commented Feb 22, 2021

DecryptSsl do not cancel the request, it just don't decrypt the request and relays the request through a TCP tunnel. The stack trace you shown suggest that it was not able to establish connection to the server, may be the zoom IP is blocked by firewall or zoom server was down.

If you want to abandon the connection, you can call e.TerminateSession() instead.
https://github.com/justcoding121/Titanium-Web-Proxy/blob/develop/src/Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs#L35

@justcoding121
Copy link
Owner

justcoding121 commented Jun 17, 2021

This was indeed a bug. Apologies. Fixed in latest beta. See #868

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants