Path: redb-route/redb.Route.Ftp/FtpConnectionFactory.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Ftp/FtpConnectionFactory.cs
----
using redb.Route.Abstractions;
using redb.Route.GenericFile;
namespace redb.Route.Ftp;
///
/// Named connection factory for FTP/FTPS. Register it in the route registry and reference it by
/// name from the endpoint URI (connectionFactory=my-ftp) so the server password never has
/// to appear in the URI, and therefore can never reach logs, telemetry, or the dashboard.
///
/// Example:
///
/// context.AddToRegistry("partner-ftp", new FtpConnectionFactory
/// {
/// Host = "ftp.partner.com", Port = 21, UseFtps = true,
/// Username = "svc-drop",
/// Password = Environment.GetEnvironmentVariable("FTP_PASSWORD")!
/// });
///
/// r.From("ftp://inbox?connectionFactory=partner-ftp") // no credentials in the route
///
///
///
public sealed class FtpConnectionFactory : RemoteFileConnectionFactory
{
/// Use passive mode (default true).
public bool PassiveMode { get; set; } = true;
/// Use FTPS (TLS).
public bool UseFtps { get; set; }
/// Validate the server TLS certificate (default true).
public bool ValidateCertificate { get; set; } = true;
///
internal override void ApplyTo(RemoteFileEndpointOptions options, EndpointUri uri)
{
base.ApplyTo(options, uri);
if (options is not FtpEndpointOptions ftp) return;
var supplied = uri.RawParameters;
if (!supplied.ContainsKey(nameof(ftp.PassiveMode))) ftp.PassiveMode = PassiveMode;
if (!supplied.ContainsKey(nameof(ftp.UseFtps))) ftp.UseFtps = UseFtps;
if (!supplied.ContainsKey(nameof(ftp.ValidateCertificate)))
ftp.ValidateCertificate = ValidateCertificate;
}
}