-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Make Kestrel config case-insensitive for certificates #23268
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
Conversation
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails without the change to ConfigurationReader.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test that multiple certs with the same name throws?
"Development" vs "DEVELOPMENT"
@@ -253,6 +253,38 @@ public void ConfigureEndpointDevelopmentCertificateGetsLoadedWhenPresent() | |||
} | |||
} | |||
|
|||
[Fact] | |||
public void ConfigureEndpointDevelopmentCertificateIsCaseInsensitive() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the change was in ConfigurationReader, you can probobly write a more targeted test in ConfigurationReaderTests. That would let you avoid some of this overhead like writing a cert to file.
https://github.com/dotnet/aspnetcore/blob/fa20111e47774b6c08f82a1f0c6373cc30e99a83/src/Servers/Kestrel/Kestrel/test/ConfigurationReaderTests.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I try to avoid file I/O (or really any I/O) in Kestrel tests if at all possible.
new KeyValuePair<string, string>("Certificates:FILECERT:Password", "certpassword"), | ||
}).Build()); | ||
|
||
Assert.Contains("An item with the same key has already been added", exception.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string is in Kestrel/Core/src/CoreStrings.resx - would it better to add a reference to that resource file to the .csproj?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CoreStrings is already InternalsVisibleTo to this project you just need to add a using for Microsoft.AspNetCore.Server.Kestrel.Core.
Updated |
var config = new ConfigurationBuilder().AddInMemoryCollection(new[] | ||
{ | ||
new KeyValuePair<string, string>("Certificates:filecert:Path", "/path/cert.pfx"), | ||
new KeyValuePair<string, string>("Certificates:FILECERT:Password", "certpassword"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still pass if the entire key is UPPERCASE, right? I know this PR only changes the dictionary comparer, but I see no reason not to verify the rest of it case insensitive while we're at it.
Hello @davidfowl! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Attempts to resolve #21494