Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Hsu <kennethhsu@gmail.com>2021-05-17 03:29:00 +0300
committerKenneth Hsu <kennethhsu@gmail.com>2021-05-17 03:29:00 +0300
commit3d8817608e81bbb06e6fc58ac68323d7769e6043 (patch)
treee2e84322453ceb209f63982a852230476114cf9d /Duplicati/Library
parentb80845a17652fe333145d90bc2509a732d02a517 (diff)
Test for ECDSA support explicitly.
The previous implementation could possibly fail for reasons unrelated to ECDSA support.
Diffstat (limited to 'Duplicati/Library')
-rw-r--r--Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs26
1 files changed, 11 insertions, 15 deletions
diff --git a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
index 2d0d1fa02..b19ac7fc4 100644
--- a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
+++ b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
@@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
@@ -335,35 +336,30 @@ namespace Duplicati.Library.Backend
private void TryConnect(SftpClient client)
{
- try
- {
- client.Connect();
- }
- catch (NotImplementedException)
+ if (Utility.Utility.IsMono)
{
// SSH.NET relies on the System.Security.Cryptography.ECDsaCng class for
// ECDSA algorithms, which is not implemented in Mono (as of 6.12.0.144).
// This prevents clients from connecting if one of the ECDSA algorithms is
- // chosen as the host key algorithm. In the event that this causes a
- // connection failure, we will prevent the client from advertising support
- // for ECDSA algorithms and make another connection attempt.
+ // chosen as the host key algorithm. In this case, we will prevent the
+ // client from advertising support for ECDSA algorithms.
//
// See https://github.com/mono/mono/blob/mono-6.12.0.144/mcs/class/referencesource/System.Core/System/Security/Cryptography/ECDsaCng.cs
- if (Utility.Utility.IsMono)
+ try
+ {
+ ECDsa.Create(default(ECCurve));
+ }
+ catch (NotImplementedException)
{
List<string> ecdsaKeys = client.ConnectionInfo.HostKeyAlgorithms.Keys.Where(x => x.StartsWith("ecdsa")).ToList();
foreach (string key in ecdsaKeys)
{
client.ConnectionInfo.HostKeyAlgorithms.Remove(key);
}
-
- client.Connect();
- }
- else
- {
- throw;
}
}
+
+ client.Connect();
}
private void ChangeDirectory(string path)