Fix connection file encryption with password protection

Changed CreateProtectedAttribute to use PasswordString as source of truth instead of Password property. This prevents encryption failures when Password property is true but _customPassword is empty.

Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-16 04:07:26 +00:00
parent 2520ccd6be
commit d736d3c388

View File

@@ -28,7 +28,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider)
{
XAttribute attribute = new(XName.Get("Protected"), "");
string plainText = rootNodeInfo.Password ? "ThisIsProtected" : "ThisIsNotProtected";
string plainText = (rootNodeInfo.PasswordString != rootNodeInfo.DefaultPassword) ? "ThisIsProtected" : "ThisIsNotProtected";
System.Security.SecureString encryptionPassword = rootNodeInfo.PasswordString.ConvertToSecureString();
attribute.Value = cryptographyProvider.Encrypt(plainText, encryptionPassword);
return attribute;