justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

Http Error 400 #905

Open ljh1991125 opened 2 years ago

ljh1991125 commented 2 years ago

Hello!

I upgraded my titanium proxy from 3.0.362 -> 3.1.1397 but the function that used to work doesn't work well. I don't know what's wrong. Chrome occurs http 400 error. I am using VS2022 and DotNet 4.5.1 Thank you for your help.

image

This is my code.

                proxyServer.BeforeRequest += OnRequest;
                proxyServer.BeforeResponse += OnResponse;
                proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
                proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;
                proxyServer.EnableTcpServerConnectionPrefetch = false;

                explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true)
                {
                    //Use self-issued generic certificate on all https requests
                    //Optimizes performance by not creating a certificate for each https-enabled domain
                    //Useful when certificate trust is not required by proxy clients
                    //GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "rootCert.pfx"), "")
                };

                //Fired when a CONNECT request is received
                explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;

                proxyServer.AddEndPoint(explicitEndPoint);
                proxyServer.Start();
ljh1991125 commented 2 years ago

PS) If i set UpstreamProxy, 400 error disappears and it works well. What's the problem?

                    proxyServer.UpStreamHttpsProxy = new ExternalProxy();
                    proxyServer.UpStreamHttpsProxy.HostName = proxy_host;
                    proxyServer.UpStreamHttpsProxy.Port = proxy_port;
                    proxyServer.UpStreamHttpsProxy.UserName = proxy_user;
                    proxyServer.UpStreamHttpsProxy.Password = proxy_pass;