Beispiel #1
0
        /// <summary>
        /// Fires the SSL certificate validation event
        /// </summary>
        /// <param name="certificate">Certificate being validated</param>
        /// <param name="chain">Certificate chain</param>
        /// <param name="errors">Policy errors if any</param>
        /// <returns>True if it was accepted, false otherwise</returns>
        protected bool OnValidateCertificate(X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            FtpSocketStreamSslValidation evt = m_sslvalidate;

            if (evt != null)
            {
                FtpSslValidationEventArgs e = new FtpSslValidationEventArgs()
                {
                    Certificate  = certificate,
                    Chain        = chain,
                    PolicyErrors = errors,
                    Accept       = (errors == SslPolicyErrors.None)
                };

                evt(this, e);
                return(e.Accept);
            }

            // if the event was not handled then only accept
            // the certificate if there were no validation errors
            return(errors == SslPolicyErrors.None);
        }
Beispiel #2
0
        /// <summary>
        /// Fires the SSL certificate validation event
        /// </summary>
        /// <param name="certificate">Certificate being validated</param>
        /// <param name="chain">Certificate chain</param>
        /// <param name="errors">Policy errors if any</param>
        /// <returns>True if it was accepted, false otherwise</returns>
        protected bool OnValidateCertificate(X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) {
            FtpSocketStreamSslValidation evt = m_sslvalidate;

            if (evt != null) {
                FtpSslValidationEventArgs e = new FtpSslValidationEventArgs() {
                    Certificate = certificate,
                    Chain = chain,
                    PolicyErrors = errors,
                    Accept = (errors == SslPolicyErrors.None)
                };

                evt(this, e);
                return e.Accept;
            }

            // if the event was not handled then only accept
            // the certificate if there were no validation errors
            return (errors == SslPolicyErrors.None);
        }