Reputation: 442
Some background:
I have a solution that consists of:
Both the IIS application and windows service are run under the same domain account. They also connect to the same database.
Database access credentials are stored in a common config file and are encrypted using the aspnet_regiis.exe tool. An ACL permission grants read access to the key container for the domain account.
The web application can access the key container and decrypt the connection string.
The service on the other hand can not access the RSA key container. I get the error:
Unexpected error attempting to connect to the database; exception: System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened. (C:\ApplicationDir\ConnectionSettings.config line 2) ---> System.Configuration.ConfigurationErrorsException: The RSA key container could not be opened.
Workarounds:
I'm leaning towards option 2, but what the heck is going on here?
Why can the application pool run under said domain account work and not the windows service which is running under the same domain account?
Is this a situation where under certain circumstances the domain account is not considered part of the Everyone group?
What's the best practice for handling this situation?
Thanks, Kevin
Upvotes: 1
Views: 4857
Reputation: 442
So it turns out that read access needs to be granted to the "NetFrameworkConfigurationKey" for the domain account.
aspnet_regiis -pa "NetFrameworkConfigurationKey" "[DOMAIN_NAME]\[USER_ACCOUNT]"
More info: http://msdn.microsoft.com/en-us/library/yxw286t2(v=vs.100).aspx
Upvotes: 5