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;
            }
        }
        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);
            }
        }
 internal CallbackContext(PolicyWrapper policyWrapper, string hostName, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     this.policyWrapper   = policyWrapper;
     this.hostName        = hostName;
     this.certificate     = certificate;
     this.chain           = chain;
     this.sslPolicyErrors = sslPolicyErrors;
 }
 internal CallbackContext(PolicyWrapper policyWrapper, string hostName, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     this.policyWrapper = policyWrapper;
     this.hostName = hostName;
     this.certificate = certificate;
     this.chain = chain;
     this.sslPolicyErrors = sslPolicyErrors;
 }
 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 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);
        }
예제 #7
0
        internal bool AcceptCertificate(TlsStream secureStream, WebRequest request)
        {
            X509Certificate newCertificate = secureStream.Certificate;

            if (ServicePointManager.CertificatePolicy != null)
            {
                PolicyWrapper cpw = new PolicyWrapper(ServicePointManager.CertificatePolicy, this, request);

                bool acceptable = secureStream.VerifyServerCertificate(cpw);
                if (!acceptable)
                {
                    return(false);
                }
            }

            m_ServerCertificate = newCertificate;
            m_ClientCertificate = secureStream.ClientCertificate;
            return(true);
        }