WIP Use machine key for encryption instead of ProtectSection()#22
WIP Use machine key for encryption instead of ProtectSection()#22ColsterJ wants to merge 9 commits into
Conversation
| if(key == "Secret") | ||
| { | ||
| //string encryptedValue = encryption.Encrypt(value); | ||
| string encryptedValue = MachineKeyEncryption.Protect(value, "Secret"); |
There was a problem hiding this comment.
The "Secret" part here should be something more unique. Possibly something like $"Secret for computer {computerKey}"
There was a problem hiding this comment.
That makes sense, I'll adjust that
|
|
||
| namespace LauncherServerClasses | ||
| { | ||
| public static class MachineKeyEncryption |
There was a problem hiding this comment.
This class is added to provide a different encryption method for hiding the secret key, locally, on the client machine. The "Protect" and "UnProtect" methods are used for encrypting and decrypting the secret key using the machine key, instead of using RSA.
|
|
||
| // We must decrypt the secret key using the machine key | ||
| //machineKeyEncryption = new Encryption("the machine key"); | ||
| secretKey = MachineKeyEncryption.UnProtect(secretKey, "Secret"); |
There was a problem hiding this comment.
The "Secret" here should match the one you changed in "SetConfigValue" - It shouldn't work if they are different.
There was a problem hiding this comment.
Ahh, I missed that. I edited the function call to match in a145cf0 and it seems to be functioning now.
| host.StartHost(); | ||
|
|
||
| //encryption = new Encryption("the machine key"); | ||
|
|
There was a problem hiding this comment.
Did you mean to leave this comment in the code?
|
|
||
| if(key == "Secret") | ||
| { | ||
| //string encryptedValue = encryption.Encrypt(value); |
There was a problem hiding this comment.
did you mean to leave this comment in the code?
|
|
||
| configuration.AppSettings.Settings[key].Value = value; | ||
| configuration.AppSettings.SectionInformation.ProtectSection(null); | ||
| //configuration.AppSettings.SectionInformation.ProtectSection(null); |
There was a problem hiding this comment.
I promise I'm gonna stop leaving this comment after this, but...
did you mean to leave this comment in the code?
please keep thinking about it as you look at this PR in total, even though I've stopped commenting.
jeanlange
left a comment
There was a problem hiding this comment.
This is a nice, tight pull request - way to go. The only thing I'd look at is removing the commented out parts. You can always find them again using git history.
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <SignManifests>true</SignManifests> | ||
| <SignManifests>false</SignManifests> |
No description provided.