diff --git a/Frends.SFTP.WriteFile/CHANGELOG.md b/Frends.SFTP.WriteFile/CHANGELOG.md index 0d3dc73..b8b2ef8 100644 --- a/Frends.SFTP.WriteFile/CHANGELOG.md +++ b/Frends.SFTP.WriteFile/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [2.2.0] - 2024-01-03 +### Updated +- [Breaking] Updated dependency SSH.NET to the newest version 2023.0.0. + +### Changed +- Changed connection info builder to create the connection info as it's done in DownloadFiles. +- [Breaking] Changed PrivateKeyFilePassphrase parameter to PrivateKeyPassphrase and enabled it when PrivateKeyString was used. + ## [2.0.1] - 2022-12-01 ### Updated - Updated dependency Microsoft.Extensions.DependencyInjection to the newest version. diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ConnectivityTests.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ConnectivityTests.cs index d044e88..870a0ab 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ConnectivityTests.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ConnectivityTests.cs @@ -22,7 +22,7 @@ public void WriteFile_TestWithLargerBuffer() public void WriteFile_TestWithPrivateKeyFileRsa() { _connection.Authentication = AuthenticationType.UsernamePasswordPrivateKeyFile; - _connection.PrivateKeyFilePassphrase = "passphrase"; + _connection.PrivateKeyPassphrase = "passphrase"; _connection.PrivateKeyFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Volumes/ssh_host_rsa_key"); SFTP.WriteFile(_input, _connection); @@ -36,7 +36,7 @@ public void WriteFile_TestWithPrivateKeyFileRsaFromString() var key = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Volumes/ssh_host_rsa_key")); _connection.Authentication = AuthenticationType.UsernamePasswordPrivateKeyString; - _connection.PrivateKeyFilePassphrase = "passphrase"; + _connection.PrivateKeyPassphrase = "passphrase"; _connection.PrivateKeyString = key; SFTP.WriteFile(_input, _connection); diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ErrorTests.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ErrorTests.cs index a8d40d5..b810fe0 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ErrorTests.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ErrorTests.cs @@ -41,22 +41,22 @@ public void WriteFile_TestThrowsWithIncorrectCredentials() public void WriteFile_TestThrowsWithIncorrectPrivateKeyPassphrase() { _connection.Authentication = AuthenticationType.UsernamePasswordPrivateKeyFile; - _connection.PrivateKeyFilePassphrase = "demo"; + _connection.PrivateKeyPassphrase = "demo"; _connection.PrivateKeyFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Volumes/ssh_host_rsa_key"); var ex = Assert.Throws(() => SFTP.WriteFile(_input, _connection)); - Assert.That(ex.Message.StartsWith("Error when initializing connection info:")); + Assert.IsTrue(ex.Message.StartsWith("Error when initializing connection info:")); } [Test] public void WriteFile_TestThrowsWithEmptyPrivateKeyFile() { _connection.Authentication = AuthenticationType.UsernamePasswordPrivateKeyFile; - _connection.PrivateKeyFilePassphrase = "passphrase"; + _connection.PrivateKeyPassphrase = "passphrase"; _connection.PrivateKeyFile = ""; var ex = Assert.Throws(() => SFTP.WriteFile(_input, _connection)); - Assert.That(ex.Message.StartsWith("Error when initializing connection info: ")); + Assert.IsTrue(ex.Message.StartsWith("Error when initializing connection info: ")); } [Test] @@ -65,11 +65,11 @@ public void WriteFile_TestThrowsWithIncorrectPrivateKeyString() var key = Helpers.GenerateDummySshKey(); _connection.Authentication = AuthenticationType.UsernamePasswordPrivateKeyString; - _connection.PrivateKeyFilePassphrase = "passphrase"; + _connection.PrivateKeyPassphrase = "passphrase"; _connection.PrivateKeyString = key.ToString(); var ex = Assert.Throws(() => SFTP.WriteFile(_input, _connection)); - Assert.That(ex.Message.StartsWith("Error when initializing connection info: ")); + Assert.IsTrue(ex.Message.StartsWith("Error when initializing connection info: ")); } [Test] diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/Helpers.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/Helpers.cs index b14ffd7..6db282a 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/Helpers.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/Helpers.cs @@ -35,9 +35,9 @@ internal static Connection GetSftpConnection() return connection; } - internal static Tuple GetServerFingerPrintAndHostKey() + internal static Tuple GetServerFingerPrintsAndHostKey() { - Tuple result = null; + Tuple result = null; using (var client = new SftpClient(_dockerAddress, 2222, _dockerUsername, _dockerPassword)) { client.ConnectionInfo.HostKeyAlgorithms.Clear(); @@ -45,7 +45,7 @@ internal static Tuple GetServerFingerPrintAndHostKey() client.HostKeyReceived += delegate (object sender, HostKeyEventArgs e) { - result = new Tuple(e.FingerPrint, e.HostKey); + result = new Tuple(e.FingerPrintMD5, e.FingerPrintSHA256, e.HostKey); e.CanTrust = true; }; client.Connect(); @@ -54,25 +54,10 @@ internal static Tuple GetServerFingerPrintAndHostKey() return result; } - internal static string ConvertToMD5Hex(byte[] fingerPrint) - { - return BitConverter.ToString(fingerPrint).Replace("-", ":"); - } - - internal static string ConvertToSHA256Hash(byte[] hostKey) - { - var fingerprint = ""; - using (SHA256 mySHA256 = SHA256.Create()) - { - fingerprint = Convert.ToBase64String(mySHA256.ComputeHash(hostKey)); - } - return fingerprint; - } - internal static string ConvertToSHA256Hex(byte[] hostKey) { var fingerprint = ""; - using (SHA256 mySHA256 = SHA256.Create()) + using (var mySHA256 = SHA256.Create()) { fingerprint = ToHex(mySHA256.ComputeHash(hostKey)); } @@ -81,7 +66,7 @@ internal static string ConvertToSHA256Hex(byte[] hostKey) internal static string ToHex(byte[] bytes) { - StringBuilder result = new StringBuilder(bytes.Length * 2); + var result = new StringBuilder(bytes.Length * 2); for (int i = 0; i < bytes.Length; i++) result.Append(bytes[i].ToString("x2")); return result.ToString(); @@ -130,7 +115,6 @@ internal static void DeleteDestinationFiles() internal static SshKeyGenerator.SshKeyGenerator GenerateDummySshKey() { var keyBits = 2048; - return new SshKeyGenerator.SshKeyGenerator(keyBits); } } diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/WriteFileTestBase.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/WriteFileTestBase.cs index ae8bdee..628c12a 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/WriteFileTestBase.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/Lib/WriteFileTestBase.cs @@ -26,7 +26,7 @@ public void SetUp() [TearDown] public void TearDown() - { + { Helpers.DeleteDestinationFiles(); } } diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ServerFingerprintTests.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ServerFingerprintTests.cs index 5b935ab..fcad0c0 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ServerFingerprintTests.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.Tests/ServerFingerprintTests.cs @@ -15,10 +15,10 @@ public class ServerFingerprintTests : WriteFileTestBase [OneTimeSetUp] public void OneTimeSetup() { - var (fingerPrint, hostKey) = Helpers.GetServerFingerPrintAndHostKey(); - _MD5 = Helpers.ConvertToMD5Hex(fingerPrint); + var (MD5, SHA256, hostKey) = Helpers.GetServerFingerPrintsAndHostKey(); + _MD5 = MD5; _Sha256Hex = Helpers.ConvertToSHA256Hex(hostKey); - _Sha256Hash = Helpers.ConvertToSHA256Hash(hostKey); + _Sha256Hash = SHA256; } [Test] diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Connection.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Connection.cs index 7e4d677..07255b7 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Connection.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Connection.cs @@ -89,9 +89,9 @@ public class Connection /// Passphrase for the private key file. /// /// passphrase - [UIHint(nameof(Authentication), "", AuthenticationType.UsernamePrivateKeyFile, AuthenticationType.UsernamePasswordPrivateKeyFile)] + [UIHint(nameof(Authentication), "", AuthenticationType.UsernamePrivateKeyFile, AuthenticationType.UsernamePasswordPrivateKeyFile, AuthenticationType.UsernamePrivateKeyString, AuthenticationType.UsernamePasswordPrivateKeyString)] [PasswordPropertyText] - public string PrivateKeyFilePassphrase { get; set; } + public string PrivateKeyPassphrase { get; set; } /// /// Fingerprint of the SFTP server. When using "Username-Password" @@ -121,6 +121,12 @@ public class Connection [DefaultValue(false)] public bool UseKeyboardInteractiveAuthentication { get; set; } + /// + /// Responses for the server prompts when using Keyboard Interactive authentication method. + /// + [UIHint(nameof(UseKeyboardInteractiveAuthentication), "", true)] + public PromptResponse[] PromptAndResponse { get; set; } = Array.Empty(); + /// /// Integer value of used buffer size as KB. /// Default value is 32 KB. diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/ConnectionInfoBuilder.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/ConnectionInfoBuilder.cs index 3fcce66..25de602 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/ConnectionInfoBuilder.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/ConnectionInfoBuilder.cs @@ -19,14 +19,21 @@ internal ConnectionInfoBuilder(Input input, Connection connect) internal ConnectionInfo BuildConnectionInfo() { ConnectionInfo connectionInfo; - List methods = new List(); + var methods = new List(); if (_connection.UseKeyboardInteractiveAuthentication) { - // Construct keyboard-interactive authentication method - var kauth = new KeyboardInteractiveAuthenticationMethod(_connection.Username); - kauth.AuthenticationPrompt += new EventHandler(HandleKeyEvent); - methods.Add(kauth); + try + { + // Construct keyboard-interactive authentication method + var kauth = new KeyboardInteractiveAuthenticationMethod(_connection.Username); + kauth.AuthenticationPrompt += new EventHandler(HandleKeyEvent); + methods.Add(kauth); + } + catch (Exception ex) + { + throw new ArgumentException($"Failure in Keyboard-Interactive authentication: {ex.Message}"); + } } PrivateKeyFile privateKey = null; @@ -34,8 +41,8 @@ internal ConnectionInfo BuildConnectionInfo() { if (string.IsNullOrEmpty(_connection.PrivateKeyFile)) throw new ArgumentException("Private key file path was not given."); - privateKey = (_connection.PrivateKeyFilePassphrase != null) - ? new PrivateKeyFile(_connection.PrivateKeyFile, _connection.PrivateKeyFilePassphrase) + privateKey = (_connection.PrivateKeyPassphrase != null) + ? new PrivateKeyFile(_connection.PrivateKeyFile, _connection.PrivateKeyPassphrase) : new PrivateKeyFile(_connection.PrivateKeyFile); } if (_connection.Authentication == AuthenticationType.UsernamePrivateKeyString || _connection.Authentication == AuthenticationType.UsernamePasswordPrivateKeyString) @@ -43,9 +50,9 @@ internal ConnectionInfo BuildConnectionInfo() if (string.IsNullOrEmpty(_connection.PrivateKeyString)) throw new ArgumentException("Private key string was not given."); var stream = new MemoryStream(Encoding.UTF8.GetBytes(_connection.PrivateKeyString)); - privateKey = (_connection.PrivateKeyFilePassphrase != null) - ? new PrivateKeyFile(stream, _connection.PrivateKeyFilePassphrase) - : new PrivateKeyFile(stream, ""); + privateKey = (_connection.PrivateKeyPassphrase != null) + ? new PrivateKeyFile(stream, _connection.PrivateKeyPassphrase) + : new PrivateKeyFile(stream); } switch (_connection.Authentication) { @@ -70,17 +77,40 @@ internal ConnectionInfo BuildConnectionInfo() throw new ArgumentException($"Unknown Authentication type: '{_connection.Authentication}'."); } - connectionInfo = new ConnectionInfo(_connection.Address, _connection.Port, _connection.Username, methods.ToArray()); - connectionInfo.Encoding = Util.GetEncoding(_input.FileEncoding, _input.EnableBom, _input.EncodingInString); + connectionInfo = new ConnectionInfo(_connection.Address, _connection.Port, _connection.Username, methods.ToArray()) + { + Encoding = Util.GetEncoding(_input.FileEncoding, _input.EnableBom, _input.EncodingInString), + ChannelCloseTimeout = TimeSpan.FromSeconds(_connection.ConnectionTimeout), + Timeout = TimeSpan.FromSeconds(_connection.ConnectionTimeout) + }; return connectionInfo; } private void HandleKeyEvent(object sender, AuthenticationPromptEventArgs e) { - foreach (var prompt in e.Prompts) - if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1) - prompt.Response = _connection.Password; + if (e.Prompts.Any()) + { + foreach (var serverPrompt in e.Prompts) + { + if (!string.IsNullOrEmpty(_connection.Password) && serverPrompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1) + serverPrompt.Response = _connection.Password; + else + { + if (!_connection.PromptAndResponse.Any() || !_connection.PromptAndResponse.Select(p => p.Prompt.ToLower()).ToList().Contains(serverPrompt.Request.Replace(":", "").Trim().ToLower())) + { + var errorMsg = $"Failure in Keyboard-interactive authentication: No response given for server prompt request --> {serverPrompt.Request.Replace(":", "").Trim()}"; + throw new ArgumentException(errorMsg); + } + + foreach (var prompt in _connection.PromptAndResponse) + { + if (serverPrompt.Request.IndexOf(prompt.Prompt, StringComparison.InvariantCultureIgnoreCase) != -1) + serverPrompt.Response = prompt.Response; + } + } + } + } } } diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/PromptResponse.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/PromptResponse.cs new file mode 100644 index 0000000..5f558b8 --- /dev/null +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/PromptResponse.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.SFTP.WriteFile.Definitions +{ + /// + /// Prompt response class for Keyboard-interactive authentication. + /// + public class PromptResponse + { + /// + /// Prompt from the server what is to be expected. + /// + /// Verification code + public string Prompt { get; set; } + + /// + /// Response for the Prompt from the server. + /// + /// 123456789 + [PasswordPropertyText] + [DisplayFormat(DataFormatString = "Text")] + public string Response { get; set; } + } +} diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Result.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Result.cs index edebed4..3d15dca 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Result.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Result.cs @@ -12,8 +12,8 @@ public class Result /// Full path to the written file. /// /// /destination/newfile.txt - [DisplayFormat(DataFormatString = "Text")] - public string Path { get; private set; } + [DisplayFormat(DataFormatString = "Text")] + public string Path { get; private set; } /// /// Size of the new file in destination. @@ -21,7 +21,7 @@ public class Result /// 3.2 public double SizeInMegaBytes { get; private set; } - internal Result(SftpFile file) + internal Result(ISftpFile file) { Path = file.FullName; SizeInMegaBytes = Math.Round((file.Length / 1024d / 1024d), 3); diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Util.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Util.cs index 2ff5996..72b330f 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Util.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Definitions/Util.cs @@ -20,7 +20,7 @@ internal static byte[] ConvertFingerprintToByteArray(string fingerprint) internal static string ToHex(byte[] bytes) { - StringBuilder result = new StringBuilder(bytes.Length * 2); + var result = new StringBuilder(bytes.Length * 2); for (int i = 0; i < bytes.Length; i++) result.Append(bytes[i].ToString("x2")); return result.ToString(); @@ -90,61 +90,60 @@ internal static Encoding GetEncoding(FileEncoding encoding, bool enableBom, stri internal static string CheckServerFingerprint(SftpClient client, string expectedServerFingerprint) { var userResultMessage = ""; + var MD5serverFingerprint = string.Empty; + var SHAServerFingerprint = string.Empty; client.HostKeyReceived += delegate (object sender, HostKeyEventArgs e) { - if (IsMD5(expectedServerFingerprint.Replace(":", "").Replace("-", ""))) - { - if (!expectedServerFingerprint.Contains(':')) - { - var serverFingerprint = BitConverter.ToString(e.FingerPrint).Replace("-", "").Replace(":", ""); + MD5serverFingerprint = e.FingerPrintMD5; + SHAServerFingerprint = e.FingerPrintSHA256; - e.CanTrust = expectedServerFingerprint.ToLower() == serverFingerprint.ToLower(); - if (!e.CanTrust) - userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + - $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{serverFingerprint}'."; - } - else - { - var serverFingerprint = BitConverter.ToString(e.FingerPrint).Replace('-', ':'); - - e.CanTrust = e.FingerPrint.SequenceEqual(ConvertFingerprintToByteArray(expectedServerFingerprint)); - if (!e.CanTrust) - userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + - $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{serverFingerprint}'."; - } - - } - else if (IsSha256(expectedServerFingerprint)) + if (!string.IsNullOrEmpty(expectedServerFingerprint)) { - if (TryConvertHexStringToHex(expectedServerFingerprint)) + if (IsMD5(expectedServerFingerprint.Replace(":", "").Replace("-", ""))) { - using (SHA256 mySHA256 = SHA256.Create()) + if (!expectedServerFingerprint.Contains(':')) { - var sha256Fingerprint = ToHex(mySHA256.ComputeHash(e.HostKey)); - - e.CanTrust = (sha256Fingerprint == expectedServerFingerprint); + e.CanTrust = expectedServerFingerprint.ToLower() == MD5serverFingerprint.Replace(":", "").ToLower(); if (!e.CanTrust) userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + - $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{sha256Fingerprint}'."; + $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{MD5serverFingerprint}'."; } + else + { + e.CanTrust = e.FingerPrint.SequenceEqual(ConvertFingerprintToByteArray(expectedServerFingerprint)); + if (!e.CanTrust) + userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + + $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{MD5serverFingerprint}'."; + } + } - else + else if (IsSha256(expectedServerFingerprint)) { - using (SHA256 mySHA256 = SHA256.Create()) + if (TryConvertHexStringToHex(expectedServerFingerprint)) + { + using (var mySHA256 = SHA256.Create()) + { + SHAServerFingerprint = ToHex(mySHA256.ComputeHash(e.HostKey)); + } + e.CanTrust = (SHAServerFingerprint == expectedServerFingerprint); + if (!e.CanTrust) + userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + + $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{SHAServerFingerprint}'."; + } + else { - var sha256Fingerprint = Convert.ToBase64String(mySHA256.ComputeHash(e.HostKey)); - e.CanTrust = (sha256Fingerprint == expectedServerFingerprint || sha256Fingerprint.Replace("=", "") == expectedServerFingerprint); + e.CanTrust = (SHAServerFingerprint == expectedServerFingerprint || SHAServerFingerprint.Replace("=", "") == expectedServerFingerprint); if (!e.CanTrust) userResultMessage = $"Can't trust SFTP server. The server fingerprint does not match. " + - $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{sha256Fingerprint}'."; + $"Expected fingerprint: '{expectedServerFingerprint}', but was: '{SHAServerFingerprint}'."; } } - } - else - { - userResultMessage = "Expected server fingerprint was given in unsupported format."; - e.CanTrust = false; + else + { + userResultMessage = "Expected server fingerprint was given in unsupported format."; + e.CanTrust = false; + } } }; diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.cs b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.cs index 60004bd..cea85bc 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.cs +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.cs @@ -16,7 +16,7 @@ public class SFTP /// /// Transfer connection parameters /// Write options with full path and string content - /// Result object {string Path, double SizeInMegaBytes} + /// Object {string Path, double SizeInMegaBytes} public static Result WriteFile([PropertyTab] Input input, [PropertyTab] Connection connection) { ConnectionInfo connectionInfo; @@ -59,8 +59,8 @@ public static Result WriteFile([PropertyTab] Input input, [PropertyTab] Connecti if (!client.IsConnected) throw new ArgumentException($"Error while connecting to destination: {connection.Address}"); - var encoding = Util.GetEncoding(input.FileEncoding, input.EnableBom, input.EncodingInString); - + var encoding = Util.GetEncoding(input.FileEncoding, input.EnableBom, input.EncodingInString); + switch (input.WriteBehaviour) { case WriteOperation.Append: diff --git a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.csproj b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.csproj index 82040c8..9a1c8ba 100644 --- a/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.csproj +++ b/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile/Frends.SFTP.WriteFile.csproj @@ -7,7 +7,7 @@ Frends.SFTP.WriteFile Frends.SFTP.WriteFile - 2.0.1 + 2.2.0 Frends Frends Frends @@ -29,7 +29,7 @@ - +