저는 며칠 동안이 일을 해왔으며 내가 잘못하고있는 것을 볼 수 없습니다. 누군가 내가 잘못하고있는 것을 보여줄 수 있다면 고맙겠습니다.내부 키를 사용하여 AspNet Core IDataProtection Azure 저장소가 왜입니까
여러 번 반복했습니다. 이것은 제가 현재 작동하지 않는 것입니다. get 메소드의
Startup.cs
var creds = new StorageCredentials(settings.CloudStorageAccount, settings.CloudStorageKey);
var account = new CloudStorageAccount(creds, true);
var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference($"{dpsFolder}-{_env.EnvironmentName}".ToLower());
container.CreateIfNotExistsAsync().GetAwaiter().GetResult();
services.AddDataProtection()
.SetApplicationName(settings.ApplicationName)
.PersistKeysToAzureBlobStorage(container, dpsFileName);
컨트롤러의 ctor
public ExternalSettingController([FromServices] IExternalSettingRepo repo,
[FromServices] IOptions<AppSettings> opts,
[FromServices] ILogger<ExternalSettingController> logger,
[FromServices] IHostingEnvironment env,
[FromServices] IDataProtectionProvider dpp)
: base(opts, repo, logger)
{
_dataProtector = dpp.CreateProtector("blah.Integration");
}
실제 호출은
toReturn.Plain = _dataProtector.Unprotect(found.SettingValue);
모든 내가 통해 말할 수있는 최선 확인을로드 할 것 디버거. 설정이 정확합니다. Unprotect에 대한 호출이 이루어지면 시스템은 Azure Blob Storage에 업로드 된 키 대신 C : \ Users \ blah \ AppData \ Local \ ASP.NET \ DataProtection-Keys의 키 중 하나를 사용하도록 선택합니다.
사물에 영향을 줄 수있는 약간의 배경. 원래 프로젝트에 대해 유지 관리하는 키를 사용하여 IDataProtection을 사용하여 암호화를 수행하는 별도의 DataProtectionService 클래스를 만들었습니다. 그건 Azure에서 읽을 수있는 장소에 설치되지 않기 때문에 저장 장소를 전환해야했습니다. 바로 Azure Storage의 핵심입니다. 해독하려고하는 데이터는 원래 동일한 키가 로컬에 저장된 경우 원래 암호화되었습니다.
내가 뭘 잘못하고 있니?
@ Mr Lister 편집자 주셔서 감사합니다. –