-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Tidy up some irregularities in certificate reloading #46819
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.
I split this out because I think it's nice to have invariants on the value of DefaultCertificate - in particular, that it's only set if IsDevCertLoaded is true. I could live with letting tests set the real one if people feel strongly.
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.
So DefaultCertificate should be renamed to DevCertificate?
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.
The naming isn't really consistent. At this point, it's the developer certificate retrieved from CertificateManager (or null).
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 you added these other properties to distinguish where the cert is coming from, it does make sense to rename DefaultCertificate to DeveloperCertificate.
|
CI failure looks legit - locally I have a dev cert in certmgr, but the CI machines don't. I'll figure out how to add that backstop to the tests. Edit: fixed |
1. Values from the user 2. Values set explicitly for test purposes 3. Values from IConfiguration 4. Values from CertificateManager Note that these are all stored in separate places, so it's possible to "undo" changes if one goes away. Also, make clearing of the IConfiguration cert on reload explicit.
Otherwise, a configuration error - e.g. a bad endpoint certificate password - could cause it to be left in a bad state, causing issues during subsequent reloads.
|
Force push is a rebase resolving (test-only) merge conflicts with #46868. |
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 you added these other properties to distinguish where the cert is coming from, it does make sense to rename DefaultCertificate to DeveloperCertificate.
Tidy up some irregularities in certificate loading
Address some issues that arise when certificate configuration changes happen while the server is running.
Description
While validating #46296, I noticed some irregularities in the way certificates are reloaded when (e.g.) appsettings.json is changed while the server is running.
KestrelServerOptions.DefaultCertificatewasn't being cleared. To improve clarity and address this issue, I've split out the possible sources of the default certificate - this makes the precedence explicit and allows the state of each to be managed separately.Reloadhave completed. (It's still not atomic, but failures in the actual state change code are too unlikely to justify additional complexity.)