Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added KeyContainer for storing RSA keys #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

added KeyContainer for storing RSA keys #9

wants to merge 1 commit into from

Conversation

nordbo
Copy link

@nordbo nordbo commented Jan 3, 2016

Hi. I've updated the code, using a KeyContainer to store the RSA keys. If the keyset does not exist, they are created, and if they exist they are obtained from the container. See https://msdn.microsoft.com/en-us/library/tswxhw92(v=vs.110).aspx for more information.

@mrsheepuk
Copy link
Owner

Interesting! I have been trying something similar out in this branch but yours is a much more straightforward way of reaching the same result.

I'll have a look and see if I can combine your approach with what I've done in that branch.

@bragma
Copy link

bragma commented Jan 7, 2016

Out of curiosity, how does this work if used on an elastic scalable web service on azure? Multiple machines should use the same private key to sign and validate tokens, right?

@mrsheepuk
Copy link
Owner

Yes absolutely @bragma - which is why the strategy used in this pull request (or my branch) would work if used on a single machine, or used in a situation where the data protection API has been set up to share keys across multiple machines (see the documentation here for info on how this would need to be configured. I've not tried it though).

@mrsheepuk
Copy link
Owner

@bragma I've just noticed that, specifically in the case of Azure, the default DPAPI configuration should handle this so this may well "just work" - see the docs for the default settings here - specifically:

If the system is being hosted in Azure Web Sites, keys are persisted to
the “%HOME%\ASP.NET\DataProtection-Keys” folder. This folder is
backed by network storage and is synchronized across all machines
hosting the application. Keys are not protected at rest.

@mrsheepuk
Copy link
Owner

The only problem with this @nordbo is that I suspect when the key rollover occurs (by default every 90 days), the verify signature will fail so, in effect, all logged in users will be logged out. I think you'd need to use the DPAPI to "unprotect" in a custom validator for checking the signature, but I've not worked out how that should be done yet.

I may have misunderstood how the whole thing works though, any ideas? I'll try and run a few tests to see if my suspicion is correct on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants