Open
Description
This is something that came up in YARP (dotnet/yarp#86).
We should consider an "automatic" certificate selection option in Kestrel to select certificates from X509Store
based on the server name in the SNI store.
The design proposed by @davidni in the YARP issue is something like this:
- A background task periodically scans all reasonable certs from a given cert store. More on what is a reasonable cert below
- Extract all SAN entries from each reasonable cert, and build a dictionary mapping acceptable host names to certs. Wildcard entries are supported per RFC6125 section 6.4.3.
- Deterministic logic selects the best cert for a host name out of all available certs. More on the definition of best below.
- When any changes are detected, atomically swap the old dictionary with the new one
- We expose an interface that can be called from Kestrel's server cert selection callback to produce the appropriate cert for a given host name, or
null
if none match. Cert selection is always O(1) w.r.t number of bound host names, including for wildcard matches.
With "reasonable" and "best" defined as:
-
Definition of reasonable cert: Similar to Kestrel's existing logic:
1.3.6.1.5.5.7.3.1
Enhanced Key Usage oid when the extension is present- Private key is available
- Additional validity + revocation checks. we call
X509Certificate2.Verify()
to also check for revocation, whereasX509CertificateStore.Find(... validOnly: true)
(used in Kestrel's defaults) does not check revocation.
-
Definition of best cert: The most recently-issued certificate that is reasonable.
Metadata
Metadata
Assignees
Labels
This issue impacts only small number of customersIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsThis issue represents an ask for new feature or an enhancement to an existing oneThis issue is related to work on yarpThis label is used by an internal tool