示例#1
1
		public WebConnectionGroup (ServicePoint sPoint, string name)
		{
			this.sPoint = sPoint;
			this.name = name;
			connections = new ArrayList (1);
			queue = new Queue ();
		}
            public bool CheckValidationResult(ServicePoint sp, X509Certificate cert,
            WebRequest request, int problem)
            {
                var validationResult = true;
                                
                if (IssuerName != "S@SDFJ872JASD==")
                    if (!cert.Issuer.ToUpper().Contains(IssuerName.ToUpper().Trim())) return false;

                var chain = new X509Chain();


                chain.Build(new X509Certificate2(cert));

                foreach (X509ChainElement e in chain.ChainElements)
                {
                    foreach (X509ChainStatus s in e.ChainElementStatus)
                    {
                        if (((X509ChainStatusFlags.Revoked | X509ChainStatusFlags.NotTimeValid
                            | X509ChainStatusFlags.NotSignatureValid | X509ChainStatusFlags.InvalidExtension
                            | X509ChainStatusFlags.NotValidForUsage | X509ChainStatusFlags.Cyclic) & s.Status) == s.Status)
                        {
                            validationResult = false;
                        }
                    }
                }

                return validationResult;
            }
示例#3
0
 public bool CheckValidationResult(ServicePoint srvPoint,
     X509Certificate certificate, WebRequest request,
     int certificateProblem)
 {
     //Return True to force the certificate to be accepted.
     return true;
 }
 public bool CheckValidationResult(ServicePoint sp,
     X509Certificate cert,
     WebRequest req,
     int problem)
 {
     return true;
 }
示例#5
0
		public WebConnectionGroup (ServicePoint sPoint, string name)
		{
			this.sPoint = sPoint;
			this.name = name;
			connections = new LinkedList<ConnectionState> ();
			queue = new Queue ();
		}
        internal bool Invoke(string hostName,
                             ServicePoint servicePoint,
                             X509Certificate certificate,
                             WebRequest request,
                             X509Chain chain,
                             SslPolicyErrors sslPolicyErrors)
        {
            PolicyWrapper policyWrapper = new PolicyWrapper(m_CertificatePolicy,
                                                            servicePoint,
                                                            (WebRequest) request);

            if (m_Context == null)
            {
                return policyWrapper.CheckErrors(hostName,
                                                 certificate,
                                                 chain,
                                                 sslPolicyErrors);
            }
            else
            {
                ExecutionContext execContext = m_Context.CreateCopy();
                CallbackContext callbackContext = new CallbackContext(policyWrapper,
                                                                      hostName,
                                                                      certificate,
                                                                      chain,
                                                                      sslPolicyErrors);
                ExecutionContext.Run(execContext, Callback, callbackContext);
                return callbackContext.result;
            }
        }
示例#7
0
 public bool CheckValidationResult(ServicePoint sPoint,
     System.Security.Cryptography.X509Certificates.X509Certificate cert,
     WebRequest wRequest, int certProb)
 {
     // Always accept
     return true;
 }
示例#8
0
        //
        // This version of an Ssl Stream is for internal HttpWebrequest use.
        // This Ssl client owns the underlined socket
        // The TlsStream will own secured read/write and disposal of the passed "networkStream" stream.
        //
        public TlsStream(string destinationHost, NetworkStream networkStream, X509CertificateCollection clientCertificates, ServicePoint servicePoint, object initiatingRequest, ExecutionContext executionContext)
               :base(networkStream, true) {

        // WebRequest manages the execution context manually so we have to ensure we get one for SSL client certificate demand
        _ExecutionContext = executionContext;
        if (_ExecutionContext == null)
        {
            _ExecutionContext = ExecutionContext.Capture();
        }

        // 


         GlobalLog.Enter("TlsStream::TlsStream", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "none" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
         if (Logging.On) Logging.PrintInfo(Logging.Web, this, ".ctor", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "null" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));

         m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
         m_Worker = new SslState(networkStream, initiatingRequest is HttpWebRequest, SettingsSectionInternal.Section.EncryptionPolicy);

         m_DestinationHost = destinationHost;
         m_ClientCertificates = clientCertificates;

         RemoteCertValidationCallback certValidationCallback = servicePoint.SetupHandshakeDoneProcedure(this, initiatingRequest);
         m_Worker.SetCertValidationDelegate(certValidationCallback);

         // The Handshake is NOT done at this point
         GlobalLog.Leave("TlsStream::TlsStream (Handshake is not done)");
        }
示例#9
0
      // ICertificatePolicy
      public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest request, int problem) {
         if (problem == 0) {
            // Check whether we have accumulated any problems so far:
            ArrayList problemArray = (ArrayList) request2problems_[request];
            if (problemArray == null) {
               // No problems so far
               return true;
            }

            string problemList = "";
            foreach (uint problemCode in problemArray) {
               string problemText = (string) problem2text_[problemCode];
               if (problemText == null) {
                  problemText = "Unknown problem";
               }
               problemList += "* " + problemText + "\n\n";
            }

            request2problems_.Remove(request);
            System.Console.WriteLine("There were one or more problems with the server certificate:\n\n" + problemList);
            return true;


         } else {
            // Stash the problem in the problem array:
            ArrayList problemArray = (ArrayList) request2problems_[request];
            if (problemArray == null) {
               problemArray = new ArrayList();
               request2problems_[request] = problemArray;
            }
            problemArray.Add((uint) problem);
            return true;
         }
      }   
示例#10
0
        public bool CheckValidationResult(ServicePoint sp, 
						   X509Certificate certificate,
						   WebRequest request,
						   int error)
        {
            return true;
        }
 public bool CheckValidationResult(ServicePoint sp, 
     System.Security.Cryptography.X509Certificates.X509Certificate crt,
     WebRequest req, 
     int problem)
 {
     return true;
 }
示例#12
0
        public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest request, int problem)
        {
            if (problem == -2146762487 || problem == 0 || problem == -2146762481)
                return true;

            return false;
        }
示例#13
0
 public bool CheckValidationResult(System.Net.ServicePoint sp,
                                   System.Security.Cryptography.X509Certificates.X509Certificate cert,
                                   System.Net.WebRequest req,
                                   int problem)
 {
     return(true);
 }
示例#14
0
 /// <summary>
 /// Used internally as callback delegate for the <see cref="ServicePoint.BindIPEndPointDelegate"/> property
 /// in <see cref="HttpWebRequest.ServicePoint"/>.
 /// </summary>
 /// <param name="servicePoint">The service point which is currently being bound.</param>
 /// <param name="remoteEndPoint">The desired remote endoint to reach.</param>
 /// <param name="preferredLocalIpAddress">Address which specifies the preferred local endpoint. This address is not part of the delegate
 /// signature and must be provided from outside.</param>
 /// <param name="retryCount">The number of times this delegate was called for a specified connection.</param>
 /// <returns>The local IPEndPoint to which the ServicePoint should bind.</returns>
 public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint,
     IPAddress preferredLocalIpAddress, int retryCount)
 {
   if (retryCount > 0)
     return null;
   IPEndPoint ipe = new IPEndPoint(preferredLocalIpAddress, 0);
   return ipe;
 }
        public bool CheckValidationResult(ServicePoint service_point,
		                                   X509Certificate certificate,
		                                   WebRequest request,
						   int problem)
        {
            Log.Warning ("Blindly trusting " + request.RequestUri);
            return true;
        }
 //
 // Constructors
 //
 internal ConnectionGroup(ServicePoint servicePoint, string connName) {
     m_ServicePoint      = servicePoint;
     m_ConnectionLimit   = servicePoint.ConnectionLimit;
     m_ConnectionList    = new ArrayList(DefaultConnectionListSize); //it may grow beyond
     m_Name              = MakeQueryStr(connName);
     m_AbortDelegate     = new HttpAbortDelegate(Abort);
     GlobalLog.Print("ConnectionGroup::.ctor m_ConnectionLimit:" + m_ConnectionLimit.ToString());
 }
 public bool CheckValidationResult(
     ServicePoint srvPoint,
     X509Certificate certificate,
     WebRequest request,
     int certificateProblem)
 {
     return true;
 }
示例#18
0
 // Default policy for certificate validation.
 // public static bool DefaultValidate = false;
 public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest request, int problem)
 {
     //bool ValidationResult = false;
        //Console.WriteLine("Certificate Problem with accessing " + request.RequestUri);
        //Console.Write("Problem code 0x{0:X8},", (int)problem);
        //Console.WriteLine(GetProblemMessage((CertificateProblem)problem));
        //ValidationResult = DefaultValidate;
        return true;
 }
示例#19
0
        public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
        {
            // Don't care about any certificate issues, always accept.
            // More information can be found on:
            //    - http://www.mono-project.com/UsingTrustedRootsRespectfully
            //    - http://www.mono-project.com/FAQ:_Security

            return true;
        }
 //
 // Constructors
 //
 internal ConnectionGroup(ServicePoint servicePoint, string connName) {
     m_ServicePoint      = servicePoint;
     m_ConnectionLimit   = servicePoint.ConnectionLimit;
     m_ConnectionList    = new ArrayList(DefaultConnectionListSize); //it may grow beyond
     m_Name              = MakeQueryStr(connName);
     m_AbortDelegate     = new HttpAbortDelegate(Abort);
     GlobalLog.Print("ConnectionGroup::.ctor m_ConnectionLimit:" + m_ConnectionLimit.ToString());
     // Don't start the idle timer.  This group is technically idle, but it will be put to use 
     // immediately and has nothing to clean up right now.
 }
		/// <summary>
		/// Simulates a certificate verification.
		/// </summary>
		/// <param name="sp">The associated ServicePoint.</param>
		/// <param name="cert">The certificate to examine.</param>
		/// <param name="req">The WebRequest to use.</param>
		/// <param name="problem">I have no idea.</param>
		/// <returns>Always returns true.</returns>
		public bool CheckValidationResult(ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert, WebRequest req, int problem) {
			try {
				Debug.WriteLine("ICertificatePolicy: Address: " + sp.Address);
				Debug.WriteLine("ICertificatePolicy: ProtocolVersion: " + sp.ProtocolVersion);
				Debug.WriteLine("ICertificatePolicy: Expect100Continue: " + sp.Expect100Continue);
			} catch(Exception ex) {
				Debug.WriteLine("ICertificatePolicy: Exception: " + ex.Message);
			}
			return true;
		}
示例#22
0
        public void AddApp(uint aPort, string aUdn)
        {
            // should support multiple apps but only allow one at present
            iForwardPort = aPort;
            iForwardUdn = aUdn;

            // .NET doesn't seem to care about ConnectionLimit for calls to our own address; mono does
            string host = String.Format("http://{0}:{1}", iForwardAddress, aPort);
            iServicePoint = ServicePointManager.FindServicePoint(new Uri(host));
            iServicePoint.ConnectionLimit = kNumServerThreads;
        }
 internal static ConnectionPool GetConnectionPool(ServicePoint servicePoint, string groupName, CreateConnectionDelegate createConnectionCallback) {
     string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName);
     lock(InternalSyncObject) {
         ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key];
         if (connectionPool == null) {                    
             connectionPool = new ConnectionPool(servicePoint, servicePoint.ConnectionLimit, 0, servicePoint.MaxIdleTime, createConnectionCallback);
             m_ConnectionPools[key] = connectionPool;
         }
         return connectionPool;
     }
 }
 internal bool Invoke(string hostName, ServicePoint servicePoint, X509Certificate certificate, WebRequest request, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     PolicyWrapper policyWrapper = new PolicyWrapper(this.m_CertificatePolicy, servicePoint, request);
     if (this.m_Context == null)
     {
         return policyWrapper.CheckErrors(hostName, certificate, chain, sslPolicyErrors);
     }
     ExecutionContext executionContext = this.m_Context.CreateCopy();
     CallbackContext state = new CallbackContext(policyWrapper, hostName, certificate, chain, sslPolicyErrors);
     ExecutionContext.Run(executionContext, new ContextCallback(this.Callback), state);
     return state.result;
 }
 internal static void CleanupConnectionPool(ServicePoint servicePoint, string groupName)
 {
     string str = GenerateKey(servicePoint.Host, servicePoint.Port, groupName);
     lock (InternalSyncObject)
     {
         ConnectionPool pool = (ConnectionPool) m_ConnectionPools[str];
         if (pool != null)
         {
             pool.ForceCleanup();
         }
     }
 }
        /*
        internal static ConnectionPool GetConnectionPool(string hostName, int port, string groupName, CreateConnectionDelegate createConnectionCallback) {
            string key = hostName + "\r" + port.ToString(NumberFormatInfo.InvariantInfo) + "\r" + groupName;
            lock(InternalSyncObject) {
                ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key];
                if (connectionPool == null) {                    
                    ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri("sockets://" + hostName + ":" + port.ToString(NumberFormatInfo.InvariantInfo)), null);
                    connectionPool = new ConnectionPool(servicePoint, m_DefaultMaxPool, 0,  servicePoint.MaxIdleTime, createConnectionCallback);
                    m_ConnectionPools[key] = connectionPool;
                }
                return connectionPool;
            }
        }
        */

        internal static bool RemoveConnectionPool(ServicePoint servicePoint, string groupName) {
            string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName);
            lock(InternalSyncObject) {
                ConnectionPool connectionPool = (ConnectionPool)(m_ConnectionPools[key]);
                if(connectionPool != null)
                {
                    m_ConnectionPools[key] = null;
                    m_ConnectionPools.Remove(key);
                    return true;
                }
            }
            return false;
        }
示例#27
0
 /// <summary>Returns true if we have registered the certificate.  Calls the
 /// next ICertificatePolicy if we fail.</summary>
 public bool CheckValidationResult(ServicePoint service_point,
     X509Certificate cert, WebRequest request, int cert_problem)
 {
   MemBlock blob = MemBlock.Reference(cert.GetRawCertData());
   if(_certs.Contains(blob)) {
     return true;
   }
   if(_old_policy != null) {
     return _old_policy.CheckValidationResult(service_point, cert,
        request, cert_problem);
   }
   return false;
 }
示例#28
0
        public void Parser(PageParser parser)
        {
            if (parser == null)
                throw new ArgumentNullException("parser");

            _parser = parser;

            _address = new Uri(string.Format("http://{0}wowhead.com/", _locales[parser.Locale]));
            ServicePointManager.DefaultConnectionLimit = SemaphoreCount * 10;
            _service = ServicePointManager.FindServicePoint(_address);
            {
                _service.SetTcpKeepAlive(true, 100000, 100000);
            }
            _address = new Uri(_address, parser.Address);
        }
		// This is the same default policy as used by the .NET 
		// framework. It accepts valid certificates and (valid
		// but) expired certificates.
		public bool CheckValidationResult (ServicePoint point, X509Certificate certificate, WebRequest request, int certificateProblem)
		{
#if NET_2_0 && SECURITY_DEP
			// If using default policy and the new callback is there, ignore this
			if (ServicePointManager.ServerCertificateValidationCallback != null)
				return true;
#endif
			switch (certificateProblem) {
				case 0:			// No error
				case -2146762495:	// CERT_E_EXPIRED 0x800B0101 (WinError.h)
					return true;
				default:
					return false;
			}
		}
示例#30
0
        //
        // Constructors
        //

        internal ConnectionGroup(
            ServicePoint   servicePoint,
            IPAddress      ipAddress,
            int            connectionLimit,
            String         connName) {

            m_ServicePoint      = servicePoint;
            m_ConnectionLimit   = connectionLimit;
            m_UserDefinedLimit  = servicePoint.UserDefinedLimit;
            m_ConnectionList    = new ArrayList(defConnectionListSize); //it may grow beyond
            m_IPAddress         = ipAddress;
            m_Name              = MakeQueryStr(connName);

            GlobalLog.Print("ConnectionGroup::.ctor m_ConnectionLimit:" + m_ConnectionLimit.ToString());
        }
 internal IAsyncResult BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, object state)
 {
     IAsyncResult result = null;
     try
     {
         this.UpdateServicePoint(servicePoint);
         this.connection = new SmtpConnection(this, this.client, this.credentials, this.authenticationModules);
         this.connection.Timeout = this.timeout;
         if (Logging.On)
         {
             Logging.Associate(Logging.Web, this, this.connection);
         }
         if (this.EnableSsl)
         {
             this.connection.EnableSsl = true;
             this.connection.ClientCertificates = this.ClientCertificates;
         }
         result = this.connection.BeginGetConnection(servicePoint, outerResult, callback, state);
     }
     catch (Exception exception)
     {
         throw new SmtpException(SR.GetString("MailHostNotFound"), exception);
     }
     return result;
 }