数据保护密钥不持久化到Azure [英] Data Protection Keys Not Persisted To Azure

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

问题描述

我有一个ASP.NET Core应用程序托管在Azure VM的IIS中.我将扩展方法称为持久化方法,以保留它们对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天全站免登陆