【发布时间】:2013-04-12 01:43:36
【问题描述】:
我正在部署在开发网络场上的 .Net 4.0 ASP.Net Web 应用程序中通过 FormsAuthentication.Encrypt(data) 将数据加密到 cookie 中。我已经指定了一个 machineKey 属性来对 ValidationKey、DecryptionKey 和 Decryption(算法)进行硬编码。
现在,我正在尝试使用我在开发工作站上构建的应用程序来解密该 cookie。我可以通过 Request.Cookies["CookieName"] 获取 cookie,但是当我尝试通过 FormsAuthentication.Decrypt(encCookie) 解密该值时,出现以下错误:
无法验证数据。在 System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(布尔 fEncrypt, Byte[] buf, Byte[] 修饰符, Int32 start, Int32 length, Boolean useValidationSymAlgo, Boolean useLegacyMode, IVType ivType, 布尔符号数据)在 System.Web.Security.FormsAuthentication.Decrypt(字符串 encryptedTicket) 在 TuoVanitySite.Default.Page_Load(Object sender, EventArgs e) 在 c:\src\ets_2008\main\ebtDev\Sandboxes\rrozinov\TuoVanitySite\TuoVanitySite\Default.aspx.cs:line 22
这是我的网络配置中的模糊(键已被删除):
<machineKey
validationKey="keyA"
decryptionKey="keyB"
decryption="3DES"
compatibilityMode="Framework20SP1"/>
有人处理过这种 machineKey 不够用的情况吗?
【问题讨论】:
标签: asp.net forms-authentication webforms