Encrypt a custom configuration section in ASP.NET using aspnet_regiis

We use a custom configuration section (via NameValueConfigSection) to contain our settings. These settings are derived from the web.config interface via configSource.

So, the entries in web.config look something like this:

<configSections> <section name="customSettings" type="System.Configuration.NameValueSectionHandler" /> </configSections> <customSettings configSource="config\customSettings.config" /> 

We want to encrypt this customSettings.config file on our production server, so run this command as recommended by Microsoft (here: http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx )

 aspnet_regiis -pe customSettings -site 4 -app / 

And this gives the following result:

 Encrypting configuration section... Succeeded! 

However, this fails at all, leaving the file exactly as

(by the way, this command works if the encryption of a non-standard section, for example, the externalised connectionStrings section)

I was able to write a small console application that works fine, but we really want to use standard tools to perform a standard operation - can someone tell me if this is a limitation or where I'm going wrong?

Thanks:)

+4
source share
1 answer

I am comparing your code with this :

To encrypt the connectionStrings section with the DPAPI provider with the machine key store (default setting), run this command from the command line:

 aspnet_regiis -pe "connectionStrings" -app "/MachineDPAPI" -prov "DataProtectionConfigurationProvider" 

Where:

-pe specifies the configuration section for encryption.

-app indicates the virtual path of the web application. If the application is nested, specify the nested path from the root directory, for example, " /test/aspnet/MachineDPAPI "

-prov specifies the name of the provider.

I wonder if you need to specify the name of the application? And / or provider?

And their version includes attribute values ​​in quotation marks.

+3
source

All Articles