zoukankan      html  css  js  c++  java
  • 加/解密web.config

    通常而言,使用aspnet_regiis(参考-pef 和 -pdf)加密的web.config,但拷到另一台机器上后无法访问,这是因为密钥容器未被一起移植。
    1.创建一个RSA密钥容器
     aspnet_regiis -pc "MyKeys" -exp

    2.授予asp.net标识对RSA容器的访问权限
          aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

    3.在Web.config 中指定加密保护提供程序(Provider)
     <configuration>
       <configProtectedData>
         <add name="MyProvider"
       type="System.Cofiguration.RsaProtectedConfigurationProvider"
       keyContainerName="MyKeys"
       useMachineContainer="true" />
       </configProtectedData>
     </configuration>

    4. 加密<connectionStrings>节
     aspnet_regiis -pe "connectionStrings" -app "/MyApp" -prov "MyProvider"


    5. 导出RSA 密钥容器
     aspnet_regiis -px "MyKeys"  "c:\keys.xml" -pri


    6. 删除RSA密钥容器
     aspnet_regiis -pz "MyKeys"

    7.从XML中导入RSA 密钥容器
     aspnet_regiis -pi "MyKeys" "c:\keys.xml"

    8.授予asp.net标识对RSA容器的访问权限
          aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

    不过本人以为对web.config文件加密就应该每台机器的单独加密,因为导出导入密钥容器的工作更大,还不如单独加密效率高,安全性也要高一些。

  • 相关阅读:
    204. Count Primes (Integer)
    203. Remove Linked List Elements (List)
    202. Happy Number (INT)
    201. Bitwise AND of Numbers Range (Bit)
    200. Number of Islands (Graph)
    199. Binary Tree Right Side View (Tree, Stack)
    198. House Robber(Array; DP)
    191. Number of 1 Bits (Int; Bit)
    190. Reverse Bits (Int; Bit)
    189. Rotate Array(Array)
  • 原文地址:https://www.cnblogs.com/answercard/p/1325558.html
Copyright © 2011-2022 走看看