Skip to content

Conversation

@Kahbazi
Copy link
Member

@Kahbazi Kahbazi commented Jul 17, 2020

Fixes #18660

@ghost ghost added the area-servers label Jul 17, 2020
httpsOptions.ServerCertificate = LoadCertificate(endpoint.Certificate, endpoint.Name)
?? httpsOptions.ServerCertificate;

httpsOptions.ClientCertificateMode = ConfigurationReader.ClientCertificateMode ?? httpsOptions.ClientCertificateMode;
Copy link
Member

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.

return endpoints;
}

private ClientCertificateMode? ReadClientCertificateMode()
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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))

Copy link
Member Author

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?

Copy link
Member

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.

httpsOptions.SslProtocols = endpoint.SslProtocols.Value;
}

httpsOptions.ClientCertificateMode = endpoint.ClientCertificateMode ?? ConfigurationReader.ClientCertificateMode ?? httpsOptions.ClientCertificateMode;
Copy link
Member

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.

@Tratcher Tratcher merged commit 8b79720 into dotnet:master Jul 23, 2020
@Tratcher
Copy link
Member

Thanks

@Tratcher Tratcher added this to the 5.0.0-rc1 milestone Jul 23, 2020
@Kahbazi Kahbazi deleted the kahbazi/clientCertificateMode branch July 23, 2020 03:22
@kamranayub
Copy link

You're the best @Kahbazi thank you, a small quality of life improvement but much appreciated 🥇

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting the ClientCertificateMode Kestrel server option from an appsettings.json file.

5 participants