CmisSync.CertPolicyHandler.CheckValidationResult C# (CSharp) Method

CheckValidationResult() public method

public CheckValidationResult ( ServicePoint sp, X509Certificate certificate, WebRequest request, int error ) : bool
sp System.Net.ServicePoint
certificate System.Security.Cryptography.X509Certificates.X509Certificate
request System.Net.WebRequest
error int
return bool
        public bool CheckValidationResult(
            ServicePoint sp,
            X509Certificate certificate,
            WebRequest request,
            int error)
        {
            if (0 == error) {
                return true;
            }

            lock (this.storeLock) {
                X509Certificate2 cert = new X509Certificate2(certificate);
                {
                    store.Open(OpenFlags.ReadOnly);
                    bool found = store.Certificates.Contains(cert);
                    store.Close();

                    // If the certificate has been stored persistent, accept it
                    if (found) {
                        return true;
                    }
                }

                if (acceptedCerts.Contains(cert)) {
                    // User has already accepted this certificate in this session.
                    return true;
                }

                if (deniedCerts.Contains(cert)) {
                    // User has already denied this certificate in this session.
                    return false;
                }

                this.UserMessage = this.GetCertificateHR(certificate) +
                    this.GetProblemMessage((CertificateProblem)error);
                this.ShowWindow();
                switch (this.UserResponse)
                {
                case Response.CertDeny:
                    // Deny this cert for the actual session
                    deniedCerts.Add(cert);
                    return false;
                case Response.CertAcceptSession:
                    // Just accept this cert for the actual session
                    acceptedCerts.Add(cert);
                    return true;
                case Response.CertAcceptAlways:
                    // Write the newly accepted cert to the persistent store
                    store.Open(OpenFlags.ReadWrite);
                    store.Add(cert);
                    store.Close();
                    return true;
                }
            }

            return false;
        }