未保存到 Azure 的数据保护密钥 [英] Data Protection Keys Not Persisted To Azure

查看:22
本文介绍了未保存到 Azure 的数据保护密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Azure VM 的 IIS 中托管了一个 ASP.NET Core 应用程序.我调用扩展方法将它们的密钥持久化到 Azure,但那里没有存储任何东西,应用程序似乎仍在使用本地密钥.我按照这里的例子:http://intellitect.com/staying-logged-across-azure-app-service-swap/ 完全正确.事实上,当我在控制台应用程序中测试代码时,持久性工作正常.但是,当我使用此代码运行 ASP.NET Core 应用程序时,任何内容都不会持久保存到 Azure.任何想法为什么?

I have an ASP.NET Core application hosted in IIS in an Azure VM. I call the extension method to persist they key to Azure but nothing is ever stored there and the application seems to still be using local keys. I followed the example here: http://intellitect.com/staying-logged-across-azure-app-service-swap/ exactly. As a matter of fact, when I test the code in a console application, persistence works fine. However, when I run the ASP.NET Core app with this code, nothing ever gets persisted to Azure. Any ideas why?

推荐答案

我将上述回复标记为答案,因为它是正确的并且是一个重要的观点.然而,这个问题的真正答案是关键数据不会仅仅因为应用程序启动并且您调用了 PersistKeysToAzureBlobStorage(或任何其他 PersistToXXX 方法)而持久化.这只是为了配置数据保护.你可以说它是懒惰的".关键数据将与您的代码一起生成,或者框架首先调用 Protect/Unprotect,如下所示:

I marked the above response as an answer because it's correct and an important point. However, the real answer to this question is key data is not persisted just because the app starts up and you called PersistKeysToAzureBlobStorage (or any other PersistToXXX method). That's just for configuration of data protection. You can say it's "lazy". The key data will be generated with your code or the framework first calls Protect/Unprotect as in the following:

var protector = provider.CreateProtector("Some Purpose");
var enc = protector.Protect("Hello World");
...
protector.Unprotect(enc);

这篇关于未保存到 Azure 的数据保护密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆