因此,使用ASPNET_REGIIS.EXE UTIL我做了以下爲什麼在不提供keyContainerName的情況下加密Web.config文件?
//Create the container
aspnet_regiis -pc MyRSAKey -exp
//Write key to file
aspnet_regiis -px MyRSAKey MyRSAKey.xml
//Install the key into a machine-level RSA key provider.
aspnet_regiis -pi MyRSAKey MyRSAKey.xml
//Grant access to the contrainer
aspnet_regiis -pa "MyRSAKey" "NT Authority\Network service"
現在我想使用這個關鍵,我需要把它添加到web.config文件
<configProtectedData defaultProvider="MyProviderName">
<providers>
<add
name="MyProviderName"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
keyContainerName="MyRSAKey"
useMachineContainer="true" />
</providers>
現在,當我運行此命令時,它的工作原理:
aspnet_regiis -pef "sectiomName" "pathToConfigFile" -prov "MyProviderName"
問題是,無論keyContainerName具有什麼樣的值,它都能正常工作。或者甚至當我將keyContainerName從配置文件中完全取出時,它仍然有效,表明它實際上並未使用我生成並安裝的密鑰。
另外visual studio 2010甚至不認識keyContainerName(或useMachineContainer),說'keyContainerName'的名字是不允許的。
這是怎麼回事?
爲什麼使用[多個感嘆號](http://wiki.lspace.org/wiki/Multiple_exclamation_marks)? – 2011-02-08 15:24:14