在机器密钥更改期间维护 ASP.Net 成员密码
是否有实用程序或代码示例可以使用旧密钥解密,然后使用新密钥为 ASP.Net 会员用户加密密码?
Is there an utility or code sample that can decrypt with the old key, and then encrypt passwords with a new key for ASP.Net membership users?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
提到的解决方法都不适合我。
我的解决方案如下。它首先以明文形式存储密码,然后使用新的 MachineKey 再次对其进行重新加密。
机器密钥更改
None of the workarounds mentioned worked for me.
My solution is below. It involves first storing passwords in clear text and then reencrypting them again with new MachineKey.
Machine Key Change
这是我对解决方案的最佳猜测,但我还没有机会测试它。它依赖于当前提供程序的以下设置:
它还假设新的机器密钥已在配置文件中。
创建以下类(感谢 mootinator 的帮助)
在您的 web.config 中:
使用以下代码更改密码:
让我知道这是否适合您。
This is my best guess at a solution, but I haven't had a chance to test it. It relies on the following settings for your current provider:
It also assumes that the new machinekey is already in the config file.
Create the following class (thanks to mootinator for the jumpstart on this)
In your web.config:
Change the passwords with the following code:
Let me know if that works for you.
我认为您可以通过动态设置密钥来做到这一点:
您可能必须扩展
SqlMembershipProvider
(或您使用的任何内容)才能访问protected DecryptPassword
方法。I think you could do this by setting the key on the fly:
You might have to extend the
SqlMembershipProvider
(or whatever you use) to get access to theprotected DecryptPassword
method.