-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add better certificate configuration support to WebApplication #32124
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
Comments
Thanks for contacting us. We're moving this issue to the |
If IDefaultServerCertificateFeature is the source of truth, do these need to be first class methods on WebApplication? Or can they be extension methods on IApplicationBuilder? It would make them accessible to a broader audience. IDefaultServerCertificateFeature must be supplied by the server, correct? What do these APIs do if the feature is absent (e.g. HttpSys or IIS)? Throw NotSupportedException?
A more consistent approach would be:
Can you show a one line way to retrieve the cert from the store without these? |
In case I can't make it to API review tomorrow:
|
namespace Microsoft.AspNetCore.Builder
{
public class WebApplication
{
+ public X509Certificate2? Certificate { get; set; }
} namespace Microsoft.AspNetCore.Hosting.Server.Features
{
+ public interface IDefaultServerCertificateFeature
+ {
+ X509Certificate2? DefaultCertificate { get; set; }
+ } Currently approved API. @halter73 is going to speak to @javiercn about certificate loading APIs. |
Is your feature request related to a problem? Please describe.
Today if you want to configure a TLS certificate for the host in code, you have to configure Kestrel directly using
WebApplicationBuilder.WebHost.ConfigureKestrel(...)
. Kestrel is the only server we ship that supports runtime configuration of certificates currently, but it would be nice to have a way to configure the certifcate(s) to be used by anyIServer
capable of using them.It would also be nice if you could configure TLS certificates with just the
WebApplication
like you can forUrls
. Certificates can be configured per-endpoint in Kestrel (and even per-server-name using SNI), but associating certificates with endpoints and server names could prove complicated. This is especially true with the multiple places in both code and config you can define Kestrel endpoints. However, maybe we could support this for all endpoints with a known URL.To support this in a way that is testable and could at least theoretically work with other
IServers
we should add a server feature interface.IServerAddressesFeature
is the only other server feature that I know of in wide use.A clear and concise description of what the problem is.
Example: I am trying to do [...] but [...]
Describe the solution you'd like
I'm still not sure I like this, but here's one possibility:
The idea is this would basically override the default/dev cert, but certificates configured for a specific Kestrel endpoint would be preferred.
Usage Examples
Additional context
What I don't like about this proposal is that it's yet another possible source for default certificates. We will have to make sure the prioritization of these sources is clear as possible, but adding more sources can only make clarifying this harder.
@Tratcher @davidfowl
The text was updated successfully, but these errors were encountered: