/// <summary> /// Upon the initial connection, we will be presented with a banner and status /// </summary> void OnChannelConnected(FtpChannel c) { if (this.SslMode == FtpSslMode.Implicit) { // The connection should already be encrypted // so authenticate the connection and then // try to read the initial greeting. this.AuthenticateConnection(); } if (!this.ReadResponse()) { this.Disconnect(); throw new FtpCommandException(this); } if (this.SslMode == FtpSslMode.Explicit) { if (this.Execute("AUTH TLS") || this.Execute("AUTH SSL")) { this.AuthenticateConnection(); } else if (this._secNotAvailable != null) { FtpSecurityNotAvailable secna = new FtpSecurityNotAvailable(this); this._secNotAvailable(secna); if (secna.Cancel) { throw new FtpCommandException(this); } } } if (this.SslEnabled && this.DataChannelEncryption) { if (!this.Execute("PBSZ 0")) { // do nothing? some severs don't even // care if you execute PBSZ however rfc 4217 // says that PBSZ is required if you want // data channel security. //throw new FtpCommandException(this); #if DEBUG System.Diagnostics.Debug.WriteLine("PBSZ ERROR: " + this.ResponseMessage); #endif } if (!this.Execute("PROT P")) // turn on data channel protection. { throw new FtpCommandException(this); } } this.Capabilities = FtpCapability.EMPTY; }
static void OnSecurityNotAvailable(FtpSecurityNotAvailable e) { // SSL/TLS could not be negotiated with the AUTH command. // If you do not want login credentials to be sent in plain // text set the e.Cancel property true to cancel the login. // Doing so with trigger a FtpCommandException to be thrown // for the failed AUTH command. e.Cancel = false; }
/// <summary> /// Upon the initial connection, we will be presented with a banner and status /// </summary> void OnChannelConnected(FtpChannel c) { if (this.SslMode == FtpSslMode.Implicit) { // The connection should already be encrypted // so authenticate the connection and then // try to read the initial greeting. this.AuthenticateConnection(); } if (!this.ReadResponse()) { this.Disconnect(); throw new FtpCommandException(this); } if (this.SslMode == FtpSslMode.Explicit) { if (this.Execute("AUTH TLS") || this.Execute("AUTH SSL")) { this.AuthenticateConnection(); } else if (this._secNotAvailable != null) { FtpSecurityNotAvailable secna = new FtpSecurityNotAvailable(this); this._secNotAvailable(secna); if (secna.Cancel) { throw new FtpCommandException(this); } } } if (this.SslEnabled && this.DataChannelEncryption) { if (!this.Execute("PBSZ 0")) { // do nothing? some severs don't even // care if you execute PBSZ however rfc 4217 // says that PBSZ is required if you want // data channel security. //throw new FtpCommandException(this); #if DEBUG System.Diagnostics.Debug.WriteLine("PBSZ ERROR: " + this.ResponseMessage); #endif } if (!this.Execute("PROT P")) { // turn on data channel protection. throw new FtpCommandException(this); } } this.Capabilities = FtpCapability.EMPTY; }