Allow FTPS to force TLS (#21251)

Fixes #21249

Example params: `-ftp=force-tls=true -ftp="tls-private-key=ftp/private.key" -ftp="tls-public-cert=ftp/public.crt"`

If MinIO is set up for TLS those certs will be used.
This commit is contained in:
Klaus Post 2025-05-09 22:10:19 +02:00 committed by GitHub
parent 8cad40a483
commit c0a33952c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,6 +75,7 @@ func startFTPServer(args []string) {
portRange string portRange string
tlsPrivateKey string tlsPrivateKey string
tlsPublicCert string tlsPublicCert string
forceTLS bool
) )
var err error var err error
@ -103,6 +104,11 @@ func startFTPServer(args []string) {
tlsPrivateKey = tokens[1] tlsPrivateKey = tokens[1]
case "tls-public-cert": case "tls-public-cert":
tlsPublicCert = tokens[1] tlsPublicCert = tokens[1]
case "force-tls":
forceTLS, err = strconv.ParseBool(tokens[1])
if err != nil {
logger.Fatal(fmt.Errorf("invalid arguments passed to --ftp=%s (%v)", arg, err), "unable to start FTP server")
}
} }
} }
@ -129,6 +135,10 @@ func startFTPServer(args []string) {
tls := tlsPrivateKey != "" && tlsPublicCert != "" tls := tlsPrivateKey != "" && tlsPublicCert != ""
if forceTLS && !tls {
logger.Fatal(fmt.Errorf("invalid TLS arguments provided. force-tls, but missing private key --ftp=\"tls-private-key=path/to/private.key\""), "unable to start FTP server")
}
name := "MinIO FTP Server" name := "MinIO FTP Server"
if tls { if tls {
name = "MinIO FTP(Secure) Server" name = "MinIO FTP(Secure) Server"
@ -147,6 +157,7 @@ func startFTPServer(args []string) {
Logger: &minioLogger{}, Logger: &minioLogger{},
PassivePorts: portRange, PassivePorts: portRange,
PublicIP: publicIP, PublicIP: publicIP,
ForceTLS: forceTLS,
}) })
if err != nil { if err != nil {
logger.Fatal(err, "unable to initialize FTP server") logger.Fatal(err, "unable to initialize FTP server")