故事是我使用此命令
成功加密了我的app.config文件apsnet_regiis -pe "AppSettings" D:\
我首先将app.config
更改为web.config
文件,将其放入D:\
云端硬盘,已加密web.config
,将其重命名为app.config
并将其放入我的解决方案文件夹,问题是,当我运行我的应用程序时,它会抛出以下错误:
Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.
我想知道我的程序如何阅读它,我还要注意,我使用了
apsnet_regiis -pa "AppSettings" D:\
要解密我的app.config
文件,但会抛出一条错误,指出:
The RSA key container is not found
我搜索了这个错误的线索,他们中的大多数都告诉我在同一台机器上解密加密文件,但是我在同一台机器上解密文件。
这是我加密的app.config文件
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="constr" connectionString="Provider=SQLOLEDB.1;Password=fuji!5M;User ID=sa;Initial Catalog=Training;Data Source=FMDBMS01;" />
</connectionStrings>
<appSettings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>DfiTaM8CAa3/LOKxgPhPg5iyzF756SOEp9mTkwGGqQAoVuLZHRepfFYGbKbz3FLI3jFv6WDg2ixwBZWeGErEGnJGMB5Etcmgmt3Ck/y0tdy0/dmm6QgaUzd7lvoZifu81G34XVoZHYX8WsPrONL5YygdUMrziV0TSgaaycpfREw=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>Q/oZj8T9o76FFxO9vZ+I8X5Xq0xuaCNo9I5/4a74ZE9FTwESIA9k3ML75HnmPNfx+0okVWMmf/w7YKESUgDk1It9saudpNyetZWT/lYgRTTB4BRbMc9M1YtYBErSGn4GUPPLuj0pP+WgC3zTe+bDSpls9cdIwcwKelpu4l9hLp/VHGWui+3u1iWmHs/d+0X9BtRFTUsjyOLUEjZnlSsiEW7eK85MswVsyxqoKUGm8QWCjt/uQc13RwIy42rHrfZqG8Zwer0woye6runE2jzH7GQPi+LolYFSq6WNJgazxFvVzrqKycVpD9PJHJFBMu2FZ0ym3ZRlfpFzNNz/Nb4O/8IwKmrmPCt6GfjvvjuOrvU=</CipherValue>
</CipherData>
</EncryptedData>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
</providers>
</roleManager>
</system.web>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
谢谢你,最诚挚的问候。
编辑:这是关于如何加密我的连接字符串的第一个问题,似乎我不能让RSA加密并读取我的连接字符串,我可以加密它,但我的软件无法读取它。