0

I want to encrypt common.config, not the Web.config file. Common.config is in a different location than the web.config. The web.config file is connected to the common.config.

web.config:

<appSettings file="C:\Users\ja\Documents\common.config">
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

common.config:

<appSettings>
    <add key="myKey" value="This is the Value"/>
</appSettings>`

This works for the web.config file:

aspnet_regiis.exe -pef appSettings c:\Users\ja\Desktop\test\webapp\webapp -prov "RsaRpotectedConfigurationProvider"

But when I try to encrypt the common.config file:

aspnet_regiis.exe -pef appSettings c:\Users\ja\Document\ -prov "RsaRpotectedConfigurationProvider"

I get this error:

The configuration for physical path 'c:\Users\ja\Document\' cannot be opened
User765876
  • 135
  • 2
  • 11

2 Answers2

1

I found workaround to solve this issue. Hope it helps.

  1. Rename your common.config to web.config temporarily.

  2. Add configuration as root element to this file. So your common.config will look like as follows.

<configuration>
  <appSettings>
    <add key="myKey" value="This is the Value"/>
  </appSettings>
</configuration>
  1. Run encrypt command.

    aspnet_regiis.exe -pef appSettings c:\Users\ja\Document\ -prov "RsaProtectedConfigurationProvider"

  2. Open encrypted file and remove Configuration tags.

  3. Rename file to Common.config PS: I deleted my original comments posted on this thread.

Pankaj Kapare
  • 7,486
  • 5
  • 40
  • 56
0

It doesn't look like you supplied the full path:

c:\Users\ja\Document\

vs

C:\Users\ja\Documents\common.config

If the syntax requires the directory, Document is still missing the 's'

David
  • 137
  • 1
  • 2
  • 10
  • It looks like the path parameter is supposed to point to a web application. Perhaps move the common.config to the root of an application rather than the Documents folder? – David Jan 16 '15 at 19:45
  • The same way it decrypts the web.config. – User765876 Jan 16 '15 at 20:21