0
votes

I have "Class library projet" which works as HttpHandler later at a webserver. So I have locally 2 files app.config (for local dev, because it is a dll) and web.config (for remote web server).

So now I wanted to encrypt config file. Everything was encrypted and imported at remote web server. But the handler doesn't work. I receive an error: "Failed to decrypt using provider 'My_Provider'. Error message from the provider: The RSA key container could not be opened."

At my dev PC everything works fine. What is wrong?

So this my export steps

cd %windir%\Microsoft.NET\Framework\v4.0.30319

aspnet_regiis -pc "My_Keys" -exp

aspnet_regiis -pa "My_Keys" "IIS APPPOOL\CustomAppPool"

aspnet_regiis -pef "connectionStrings" "HandlerProjectPath" -prov "My_Provider"

aspnet_regiis -px "MyKeys" "HandlerProjectPath\MyKeys.xml" -pri

pause

these are import step

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pi "My_Keys" "MyKeys.xml"

pause

p.s. My handler works at IIS 7 inside my custom AppPool with name "CustomAppPool". I specially created an app pool name at my PC.

this is my configData

Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"

       keyContainerName="My_Keys"
       useMachineContainer="true" />
</providers>   </configProtectedData>

Thanks in advance!

1

1 Answers

1
votes

I think you need to grant access to the container to the IIS Identity assigned to your AppPool, after you import the key pair.