Cannot decrypt data if encrypted by another app that uses ILMerge
mcm-ham opened this issue · 2 comments
In our app we are looking at implementing an encrypted config file using a custom provider that uses DataProtector. To support administrators editing this config file we wrote a simple EncryptedSettings console app they can use to decrypt config file to edit and once finished re-encrypt. Since DataProtector brings in a lot of dlls we're using ILMerge to consolidate into a single exe. The problem is the key saved to disk has this reference:
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, EncryptedSettings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
So in our application the config provider can't decrypt file because it can't find the EncryptedSettings dll (which of course was originally Microsoft.AspNetCore.DataProtection.dll before it was merged into the tools exe).
@mcm-ham, as you have pointed out, we add the Deserializer type name to the key so we know what instance of the deserializer to create when decrypting the key (
IKeyManager
doesn't support it. @blowdart might have a better explanation.Sounds about right. As we need to discover the provider, and the way we do that is embedding the dll name into the key using ILMerge is just not going to work.