-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Kestrel] HTTPS with ServerCertificateSelector, build full chain every connection, who to cache it? #46117
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
Can you show your There's 2 ways to handle this:
If you choose 2, then you'll need to use the OnAuthenticate callback instead. Getting the host name is a little more complex though (I believe you can get it from the underlying SSlStream instance). o.OnAuthenticate = (ctx, options) =>
{
var sni = ctx.Features.Get<SslStream>()?.TargetHostName;
if (!string.IsNullOrWhiteSpace(sni) && KnownCertificates.GetCertificate(sni) is { } certContext)
{
options.ServerCertificateContext = certContext;
}
else
{
ctx.Abort();
}
}; If you're unable to get the host name then we need to look at providing a simpler API to get it. |
X509Certificate2.CreateFromPemFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cert.crt"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cert.key")) Default loaded at start of app of cource, other certificates loaded at startup and HUP signal. thanks, i will try those ways. |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
@davidfowl , any tips where to look? |
I decided to switch to TlsHandshakeCallbackOptions, where there is no issue with SNI. |
Hello, issue happened with YARP, but code itself is Kestrel actually.
I had implemented dynamic certificate loading(by reload command),
which worked fine so far with Let's Encrypt certificates and others, where CA is known to system.
But we added other certificate which have it's own CA, which is not known to system.
Under load handshake time increases dramaticaly, by doing dotnet-stack report, i found that most thread where stuck with building full chain:
since simple load is handled nicely, but still connection time was bigger in comparison with other domains, i assume that any https-connection is doing that code.
After i added that CA into system, handshake does not hangs any more.
But looks like every connection does building full chain.
Is there is the way to precache it? so i can do that once when i load certificate into memory?
I took stacktrace from .net 7, but .net 6 had same bottleneck.
The text was updated successfully, but these errors were encountered: