0

I am developing a .NET Core solution in Visual Studio 2015 on a MacBook Pro 2016 year model using bootcamp.

At the moment we are running on 1.0.0-rc1-final of the sdk. We are working on upgrading but it will take some time.

I have a real problem with the Data Protection framework. I configure DataProtection to persist keys to the local file system using:

services.ConfigureDataProtection(configure => configure.PersistKeysToFileSystem(new DirectoryInfo(_configFolderPath)));

The problem is when I run the solution and do a call to the application the encryption key is not created. My colleague who is working on a PC laptop (We are both running Windows 10) run the exact same code base (From the same commit) and for him the key is created.

I get no errors what so ever. Is this a problem with the MacBook hardware not being able to be used to create the key or have anyone run in to this problem?

tveitan
  • 41
  • 8
  • There should be no difference at all due to hardware. Have you tried turning on console logging to verbose and seeing if anything is revealed? – blowdart Sep 16 '16 at 21:04
  • @blowdart Hey, thanks for the interest. Yes, I have run the solution with verbose logging and get no information about key creation in any way. Which is strange considering my colleague, when he runs the solution, gets the keys created as soon as he access the application. – tveitan Sep 20 '16 at 06:43
  • Did you ever find the solution? Same behavior here. – Lavamantis Sep 26 '22 at 21:33

2 Answers2

3

That's an odd way to configure it. Generally we expect you to configure when you set it up.

Try

public void ConfigureServices(IServiceCollection services)
{
    services.AddDataProtection()
        .PersistKeysToFileSystem(new DirectoryInfo(_configFolderPath));

}

By the time it's in the services collection it's too late to change things, which is when your configuration approach is kicking in.

blowdart
  • 55,577
  • 12
  • 114
  • 149
  • Thanks for the information @blowdart. At the moment we are running on `1.0.0-rc1-final` of the sdk. (I updated the question with this aswell). In this version from what I can see you cannot configure DataProtection the way you described. Am I still initiating it the wrong way? – tveitan Sep 22 '16 at 08:02
  • Oh it's been such a while ago now I honestly can't remember. I think that feels right for RC1. Can you turn verbose logging on? That way you'd get a bunch of debug information. – blowdart Sep 22 '16 at 12:10
0

Looking at tveitan's code and realising it is much the same as mine, and I am upgrading to RTM, I can confirm that what blowdart says works with the new package at least.

Tryggen
  • 103
  • 1
  • 7