Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I encrypt web.config with a custom protection provider who's assembly is not in the GAC?

I have written a custom protected configuration provider for my web.config.

When I try to encrypt my web.config with it I get the following error from aspnet_iisreg

aspnet_regiis.exe -pef appSettings . -prov CustomProvider (This is running in my MSBuild)

Could not load file or assembly 'MyCustomProviderNamespace' or one of its dependencies. The system cannot find the file specified.

After checking with the Fusion log, I confirm it is checking both the GAC, and 'C:/WINNT/Microsoft.NET/Framework/v2.0.50727/' (the location of aspnet_iisreg). But it cannot find the provider.

I do not want to move my component into the GAC, I want to leave the custom assembly in my ApplicationBase to copy around to various servers without having to pull/push from the GAC.

Here is my provider configuration in the web.config.

<configProtectedData>
  <providers>
    <add name="CustomProvider"
         type="MyCustomProviderNamespace.MyCustomProviderClass,
         MyCustomProviderNamespace" />
  </providers>
</configProtectedData>

I want aspnet_iisreg to check my ApplicationBase Bin folder for this assembly. Has anyone got any ideas?

like image 251
James Avatar asked May 20 '10 09:05

James


1 Answers

Bit dirty, what I ended up doing was adding the DLL doing the encryption to the GAC of the build machine. This encrypted the config okay.

When deploying the solution, I copied the Dll into the ApplicationBase, the application was able to decrypt it succesfully.

like image 184
James Avatar answered Nov 03 '22 00:11

James