Example #1
0
        /// <summary>
        /// Fires the SSL validation event
        /// </summary>
        /// <param name="e">Event Args</param>
        private void OnValidateCertficate(FtpSslValidationEventArgs e)
        {
            FtpSslValidation evt;

            evt = m_sslvalidate;
            if (evt != null)
            {
                evt(this, e);
            }
        }
Example #2
0
        /// <summary>
        /// Fires the SSL validation event
        /// </summary>
        /// <param name="e">Event Args</param>
        private void OnValidateCertficate(FtpSslValidationEventArgs e)
        {
            // automatically validate if ValidateAnyCertificate is set
            if (ValidateAnyCertificate)
            {
                e.Accept = true;
                return;
            }

            // fallback to manual validation using the ValidateCertificate event
            m_ValidateCertificate?.Invoke(this, e);
        }
Example #3
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);
        }
Example #4
0
 /// <summary>
 /// Catches the socket stream ssl validation event and fires the event handlers
 /// attached to this object for validating SSL certificates
 /// </summary>
 /// <param name="stream">The stream that fired the event</param>
 /// <param name="e">The event args used to validate the certificate</param>
 private void FireValidateCertficate(FtpSocketStream stream, FtpSslValidationEventArgs e)
 {
     OnValidateCertficate(e);
 }