mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-23 01:28:36 +08:00
when decrypting xml cred repos, we must be able to decrypt the auth header
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
@@ -30,6 +31,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
if (string.IsNullOrEmpty(xml)) return xml;
|
||||
var xdoc = XDocument.Parse(xml);
|
||||
var cryptoProvider = new CryptoProviderFactoryFromXml(xdoc.Root).Build();
|
||||
DecryptAuthHeader(xdoc.Root, cryptoProvider, key);
|
||||
foreach (var credentialElement in xdoc.Descendants())
|
||||
{
|
||||
var passwordAttribute = credentialElement.Attribute("Password");
|
||||
@@ -39,5 +41,13 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
}
|
||||
return xdoc.ToString();
|
||||
}
|
||||
|
||||
private void DecryptAuthHeader(XElement rootElement, ICryptographyProvider cryptographyProvider, SecureString key)
|
||||
{
|
||||
var authAttribute = rootElement.Attribute("Auth");
|
||||
if (authAttribute == null)
|
||||
throw new EncryptionException("Could not find Auth header in the XML repository root element.");
|
||||
cryptographyProvider.Decrypt(authAttribute.Value, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user