-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Load ClientCertificateMode from config #24076
Load ClientCertificateMode from config #24076
Conversation
@@ -293,6 +293,8 @@ public void Load() | |||
httpsOptions.ServerCertificate = LoadCertificate(endpoint.Certificate, endpoint.Name) | |||
?? httpsOptions.ServerCertificate; | |||
|
|||
httpsOptions.ClientCertificateMode = ConfigurationReader.ClientCertificateMode ?? httpsOptions.ClientCertificateMode; |
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.
Organization: This was inserted between to related code sections dealing with server certs. Move it up above line 293.
@@ -100,6 +104,16 @@ private IEnumerable<EndpointConfig> ReadEndpoints() | |||
return endpoints; | |||
} | |||
|
|||
private ClientCertificateMode? ReadClientCertificateMode() |
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 only supports a global setting, not a setting per endpoint?
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.
I couldn't find the code which options for each endpoint is being set from config. Could you point me to it please?
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.
SslProtocols = ParseSslProcotols(endpointConfig.GetSection(SslProtocolsKey)) |
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.
Uhhmm. I'm confused! EndpointConfig
doesn't have a ClientCertificateMode
property. Am I missing something? Is it even possible to set ClientCertificateMode
per endpoint?
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.
EndpointConfig is an internal config construct, you should add ClientCertificateMode there.
@@ -289,9 +289,11 @@ public void Load() | |||
httpsOptions.SslProtocols = endpoint.SslProtocols.Value; | |||
} | |||
|
|||
httpsOptions.ClientCertificateMode = endpoint.ClientCertificateMode ?? ConfigurationReader.ClientCertificateMode ?? httpsOptions.ClientCertificateMode; |
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.
I think we should apply the global ConfigurationReader.ClientCertificateMode before calling ApplyHttpsDefaults then apply endpoint.ClientCertificateMode afterwards. This way global config doesn't override what was done in code via ConfigureHttpsDefaults. Our handling of SslProtocols is very similar.
We should also add some KestrelConfigurationLoader tests to verify whatever behavior we decide on.
Thanks |
You're the best @Kahbazi thank you, a small quality of life improvement but much appreciated 🥇 |
Fixes #18660