2017-11-21 14 views
0
<?xml version="1.0"?> 
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
<appSettings configSource="appSettings.config"/> 
<connectionStrings configSource="connections.config"/> 
<system.web> 
<compilation debug="true" /> 
<authentication mode="Windows"/> 
<identity impersonate="true"/> 
</system.web> 
</configuration> 

上記web.configは、MVC Webアプリケーションで使用されています。 RsaProtectedConfigurationProvideraspnet_regiisで暗号化しようとしました。しかし、単純にWeb.configで期待通りに動作しません。appSettingsconnectionStringsが同じファイルに存在します。web.configで外部appSettingsとconnectionStringsを暗号化できますか?

私は、web.configファイル

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "connectionStrings" "D:\WebApplication" -prov "AppEncryptionProvider". 

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "appSettings" "D:\WebApplication" -prov "AppEncryptionProvider". 

を暗号化するためにコマンドを使用していますが、以下のように、Webアプリケーションでこれを使用している間、それは私にエラーを与える:プロバイダを使用して復号化に失敗しました「AppEncryptionProvider」。プロバイダからのエラーメッセージ:指定されたファイルが見つかりません。 (HRESULTからの例外:0x80070002)

Line 1: <appSettings configProtectionProvider="AppEncryptionProvider"> 
Line 2: <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" 
Line 3:  xmlns="http://www.w3.org/2001/04/xmlenc#"> 
Line 4:  <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /> 

答えて

0

はい。プロバイダとサイト名を渡して、以下のコマンドでこれを行うことができます。

  • {0} web.configファイルで指定されたあなたの暗号化プロバイダの名前です:

    aspnet_regiis -pe "appSettings" -prov "{0}" -site {1} -app "/" 
    

  • {1} IIS
  • であなたのサイトのID

同様の質問です: Encrypting AppSettings in file external to Web.Config

+0

そして、これは 'appSettings.config'と' connection.config'ファイルを暗号化するのだろうか?あるいは、 'web.config'で直接何が暗号化されるだけでしょうか? – mason

+0

これもファイルを暗号化します –

関連する問題