From bd30103758351fb078d434a8ab67bebbaf02482c Mon Sep 17 00:00:00 2001 From: David Sparer Date: Mon, 24 Oct 2016 15:39:50 -0600 Subject: [PATCH] Fixed bug where we were not using the correct encryption key during serialization --- .../Config/Serializers/XmlConnectionsDocumentCompiler.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/Config/Serializers/XmlConnectionsDocumentCompiler.cs b/mRemoteV1/Config/Serializers/XmlConnectionsDocumentCompiler.cs index 491b29e5e..15e14e198 100644 --- a/mRemoteV1/Config/Serializers/XmlConnectionsDocumentCompiler.cs +++ b/mRemoteV1/Config/Serializers/XmlConnectionsDocumentCompiler.cs @@ -13,6 +13,7 @@ namespace mRemoteNG.Config.Serializers public class XmlConnectionsDocumentCompiler { private readonly ICryptographyProvider _cryptographyProvider; + private SecureString _encryptionKey; public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider) { @@ -28,13 +29,14 @@ namespace mRemoteNG.Config.Serializers public XDocument CompileDocument(ConnectionInfo serializationTarget, bool fullFileEncryption, bool export) { var rootNodeInfo = GetRootNodeFromConnectionInfo(serializationTarget); + _encryptionKey = rootNodeInfo.PasswordString.ConvertToSecureString(); var rootElement = CompileRootNode(rootNodeInfo, fullFileEncryption, export); CompileRecursive(serializationTarget, rootElement); - var xmlDeclaration = new XDeclaration("1.0", "utf-8", ""); + var xmlDeclaration = new XDeclaration("1.0", "utf-8", null); var xmlDocument = new XDocument(xmlDeclaration, rootElement); if (fullFileEncryption) - xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, rootNodeInfo.PasswordString.ConvertToSecureString()); + xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, _encryptionKey); return xmlDocument; } @@ -75,7 +77,7 @@ namespace mRemoteNG.Config.Serializers private XElement CompileConnectionInfoNode(ConnectionInfo connectionInfo) { - var connectionSerializer = new XmlConnectionNodeSerializer(_cryptographyProvider, new SecureString()); + var connectionSerializer = new XmlConnectionNodeSerializer(_cryptographyProvider, _encryptionKey); return connectionSerializer.SerializeConnectionInfo(connectionInfo); } }