Bug 37125 - MachineKeySection.Validation not set correctly from web.config
Summary: MachineKeySection.Validation not set correctly from web.config
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: master
Hardware: PC Linux
: Normal normal
Target Milestone: Future Release
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-12-17 16:40 UTC by Csaba Halász
Modified: 2016-08-30 04:54 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
proposed patch (700 bytes, patch)
2015-12-17 17:05 UTC, Csaba Halász
Details | Diff

Description Csaba Halász 2015-12-17 16:40:17 UTC
1. Add <machineKey validation="SHA1" /> to web.config under <configuration>/<system.web>
2. Create sample asp application that queries MachineKeySection as ConfigurationManager.GetSection("system.web/machineKey");
3. Examine Validation property of above section. You will see HMACSHA256 (the default) and not SHA1 as expected.
4. Examine ValidationAlgorithm property. You will see it is properly set as SHA1.

I think this bug has been introduced by commit a22389fde254675e52a9da9c9bcd18afdec29d33 but I haven't verified.
Debugging through the code, it is doing puzzling things, such as Config.AutoGenerate in the static constructor recursively calling back to ConfigurationManager.GetSection which is in the process of creating the instance in the first place. Things somehow get messed up and we end up with a half-parsed instance, even though no less than 4 (four!) constructors have been called. Overkill when we only really want a single instance.
Comment 1 Csaba Halász 2015-12-17 17:05:36 UTC
Created attachment 14339 [details]
proposed patch

This seems to work around the issue.

Note You need to log in before you can comment on or make changes to this bug.