Merge pull request #5353 from duplicati/feature/update-aftp-to-tls13

Updating the default protocol tol TLS 1.3 if the system supports it
This commit is contained in:
Kenneth Skovhede
2024-08-01 14:21:40 +02:00
committed by GitHub
@@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Threading;
@@ -47,7 +48,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
private const FtpDataConnectionType DEFAULT_DATA_CONNECTION_TYPE = FtpDataConnectionType.AutoPassive;
private const FtpEncryptionMode DEFAULT_ENCRYPTION_MODE = FtpEncryptionMode.None;
private const SslProtocols DEFAULT_SSL_PROTOCOLS = SslProtocols.Default;
private static readonly SslProtocols DEFAULT_SSL_PROTOCOLS = SslProtocols.None; // NOTE: None means "use system default"
private const string CONFIG_KEY_AFTP_ENCRYPTION_MODE = "aftp-encryption-mode";
private const string CONFIG_KEY_AFTP_DATA_CONNECTION_TYPE = "aftp-data-connection-type";
private const string CONFIG_KEY_AFTP_SSL_PROTOCOLS = "aftp-ssl-protocols";
@@ -100,7 +101,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
{
get
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
return new List<ICommandLineArgument>([
new CommandLineArgument("auth-password", CommandLineArgument.ArgumentType.Password, Strings.DescriptionAuthPasswordShort, Strings.DescriptionAuthPasswordLong),
new CommandLineArgument("auth-username", CommandLineArgument.ArgumentType.String, Strings.DescriptionAuthUsernameShort, Strings.DescriptionAuthUsernameLong),
new CommandLineArgument("disable-upload-verify", CommandLineArgument.ArgumentType.Boolean, Strings.DescriptionDisableUploadVerifyShort, Strings.DescriptionDisableUploadVerifyLong),
@@ -110,7 +111,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
new CommandLineArgument(CONFIG_KEY_AFTP_UPLOAD_DELAY, CommandLineArgument.ArgumentType.Timespan, Strings.DescriptionUploadDelayShort, Strings.DescriptionUploadDelayLong, DEFAULT_UPLOAD_DELAY_STRING),
new CommandLineArgument(CONFIG_KEY_AFTP_LOGTOCONSOLE, CommandLineArgument.ArgumentType.Boolean, Strings.DescriptionLogToConsoleShort, Strings.DescriptionLogToConsoleLong),
new CommandLineArgument(CONFIG_KEY_AFTP_LOGPRIVATEINFOTOCONSOLE, CommandLineArgument.ArgumentType.Boolean, Strings.DescriptionLogPrivateInfoToConsoleShort, Strings.DescriptionLogPrivateInfoToConsoleLong, "false"),
});
]);
}
}
@@ -184,10 +185,8 @@ namespace Duplicati.Library.Backend.AlternativeFTP
}
// Process the aftp-encryption-mode option
string encryptionModeString;
FtpEncryptionMode encryptionMode;
if (!options.TryGetValue(CONFIG_KEY_AFTP_ENCRYPTION_MODE, out encryptionModeString) || string.IsNullOrWhiteSpace(encryptionModeString))
if (!options.TryGetValue(CONFIG_KEY_AFTP_ENCRYPTION_MODE, out var encryptionModeString) || string.IsNullOrWhiteSpace(encryptionModeString))
{
encryptionModeString = null;
}
@@ -198,10 +197,8 @@ namespace Duplicati.Library.Backend.AlternativeFTP
}
// Process the aftp-ssl-protocols option
string sslProtocolsString;
SslProtocols sslProtocols;
if (!options.TryGetValue(CONFIG_KEY_AFTP_SSL_PROTOCOLS, out sslProtocolsString) || string.IsNullOrWhiteSpace(sslProtocolsString))
if (!options.TryGetValue(CONFIG_KEY_AFTP_SSL_PROTOCOLS, out var sslProtocolsString) || string.IsNullOrWhiteSpace(sslProtocolsString))
{
sslProtocolsString = null;
}
@@ -473,7 +470,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
}
catch (Exception e)
{
if (e.InnerException != null) { e = e.InnerException; }
if (e.InnerException != null) { e = e.InnerException; }
throw new Exception(string.Format(Strings.ErrorDeleteFile, e.Message), e);
}
}