Пример #1
0
		public static void AuthenticateWithServer(proxy_transaction pt) {

			Task t = new Task(() => authenticateWithServer(pt));
			t.Start();
			t.Wait(45000);
			t.ContinueWith(c => { Exception ex = c.Exception; },TaskContinuationOptions.OnlyOnFaulted);
			if(t.Exception != null) {
				pt.Request.Errors.Add(t.Exception);
				pt.UseTunnel = true;
			}
			if(t.Status != TaskStatus.RanToCompletion){
				pt.Request.Errors.Add(new Exception("SSL Timeout!"));
				pt.UseTunnel = true;
			}
		}
Пример #2
0
        private static void authenticateWithServer(proxy_transaction pt)
        {
            try
            {
				SslStream temp = new SslStream(pt.ServerStream, false, new RemoteCertificateValidationCallback(ValidateServerCertificate));
                ///Need my own cert validation here.
                ///E.g paypal.com cert fails along with few others!
                temp.AuthenticateAsClient(pt.Request.Host,null, SslProtocols.Tls,false);
				pt.ServerStream = temp;
            }
            catch (Exception ex)
            {
				//proxied_retry_exception ex1 = new proxied_retry_exception(pt.Request,"SSL Problems",ex, 502);
				//ex1.secure = true;
				//throw ex1;
                ///Failover to direct connect Method!
                Exception newex = new Exception("Error creating SslStream. Using \"Direct Connect\" method. This error is handled but noteworthy.\r\nSee inner exception", ex);
                pt.Request.Errors.Add(newex);
                pt.UseTunnel = true;
//					pt.ServerConnection.Client = new TcpClient(pt.Request.Host, pt.Request.Port);
//	                pt.ServerStream = pt.ServerConnection.Client.GetStream();
//	                SendConnectResponse(pt);
#if DEBUG
				Console.Error.WriteLine(ex.Message);
				Console.WriteLine(ex.StackTrace);
#endif
				throw ex;
            }
        }
Пример #3
0
        public static void AuthenticateWithClient(proxy_transaction pt)
        {
            try
            {
                SslStream temp = new SslStream(pt.ClientStream, true);
#if OFFLINE_DEBUG
				((SslStream)pt.ClientStream).AuthenticateAsServer(GetDomainCert(pt.Request.Host),false,SslProtocols.Tls,true);
#else
				X509Certificate cert = GetDomainCert(pt.Request.Host);

                temp.AuthenticateAsServer
                    (cert,false,SslProtocols.Tls,false);
#endif
				pt.ClientStream = temp;
            }
            catch (Exception ex)
            {
				pt.Request.Errors.Add (ex);
#if DEBUG
				Console.Error.WriteLine(ex.Message);
				Console.Error.WriteLine(ex.StackTrace);
#endif
				throw ex;
			}
        }
Пример #4
0
        public static void SendConnectResponse(proxy_transaction pt)
        {
			//Afaik, Connect is only used by proxies...
            pt.Response = new http_response();

            pt.Response.Header.Httpversion = "HTTP/1.1";
            pt.Response.Header.Statuscode = "200";
            pt.Response.Header.Statusmessage = "Connection Established";
            pt.Response.Header.SetValue("Proxy-Connection","Keep-Alive");
			pt.Response.Header.SetValue("Proxy-Agent", String.Format("{0}/{1}",Assembly.GetEntryAssembly().GetName().Name,Assembly.GetEntryAssembly().GetName().Version));
            pt.Response.Header.SetValue("Content-Length", "0");
            pt.Response.Respond(pt.ClientConnection.Client,pt.ClientStream);
        }
		public void notify_completed(proxy_transaction pt)
		{
			Gtk.Application.Invoke (pt, new EventArgs(), (obj,e) => {
				proxy_transaction_node ptn = null;
				if(!_capture) {
					ptn = (proxy_transaction_node)_pt_list[(proxy_transaction)obj];
					lock(_pt_list) {
						if(ptn != null && _pt_list.ContainsKey(obj))
							_pt_list.Remove (ptn.pt);
						nodeview1.NodeStore.RemoveNode (ptn);
					}
				} else {
					ptn = new proxy_transaction_node((proxy_transaction)obj);
					lock(_pt_list) {
						if(!_pt_list.ContainsKey(obj))
							_pt_list.Add(obj,ptn);
						filter_this(ptn);
					}
				}
			});
		}
		public void notify_started(proxy_transaction pt)
		{
			Gtk.Application.Invoke (pt, new EventArgs(), (obj,e) => {
				proxy_transaction_node ptn = new proxy_transaction_node ((proxy_transaction)obj);
				if(!_capture) {
					lock(_pt_list) {
						if(!_pt_list.ContainsKey(obj))
							_pt_list.Add (obj, ptn);
						nodeview1.NodeStore.AddNode (ptn);
					}
				}
			});
		}
Пример #7
0
		public  proxy_transaction_node  ( proxy_transaction pt) 
		{ 
			_pt = pt;
		}