简体   繁体   中英

Grant read access to RSA encryption key through C# code

I am currently using RSACryptoServiceProvider to encrypt the app.config sections especially the connection strings. The problem is, in a group policy environment the encryption occurs when the software is installed through the administrator account. This doesn't allow the current user to decrypt the app.config sections as it doesn't have permission to access machine level key.

Right now I am using aspnet_regiis -pa "RSA key container" "User" to grant permission for a particular user to access the key container (ACL permission)

My question is: Is there a way to grant read access for current network user to access Machine level RSA key through C# code?

I would like to implement this in C# application code so that the application doesn't crash because the current user doesn't have the necessary permission to read RSA encryption key.

Apparently there is no way for a particular user with limited rights to access machine key unless he is given permission by an administrator level account.

Hence, if one installs the package through administrator account then the permission for the user needs to be granted explicitly through the administrator.

Time to change encryption method :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM