Skip to content
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

Preload intermediate certificates before exposing certificate to Kestrel #71

Merged
merged 2 commits into from
May 16, 2020

Conversation

dv00d00
Copy link
Contributor

@dv00d00 dv00d00 commented May 15, 2020

I had quite an epic issue with certificate verification in .net core.

Full details here: dotnet/aspnetcore#21183

TLDR: .net core 3.1 will perform an HTTP call to root authority of the certificate issuer to check if it was revoked. If this happens under load after a restart, threadpool is filled with blocking calls to check cert revocation, rendering app unresponsive.

@davidfowl suggested a workaround that can prevent this behavior.

There are several open questions marked as todo's in code

{
// todo: wording
// todo: throw?
_logger.LogWarning("Was not able to build certificate chain");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the VerificationFlags is AllFlags and revocation isn't requested I'm not sure (off the top of my head) if it's possible to get a false result (the only thing that would do that is ExplicitDistrust, IIRC, and we don't currently produce that on Linux).

If VerificationFlags had its default value (no flags set => all tests tested) then this would report that the intermediate couldn't be fetched (or something was expired, or something weird was going on). If that's an interesting state to differentiate, then just remove the assignment of VerificationFlags.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flags were copied from the logic that SSLStream performs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flags were copied from the logic that SSLStream performs

Yeah, SslStream is just trying to build a best-effort chain and see what it can do with that. I'm just suggesting that for logging purposes it might make sense to try to build a "normally valid" chain.

@davidfowl
Copy link

@dv00d00 it’s not revocation it’s downloading intermediates certificates. Old change the title to, populate the cache with intermediate certs before giving it to kestrel

@dv00d00 dv00d00 changed the title [WIP] Disable certificate revocation checks Preload intermediate checks before exposing certificate to Kestrel May 16, 2020
@dv00d00 dv00d00 changed the title Preload intermediate checks before exposing certificate to Kestrel Preload intermediate certificates before exposing certificate to Kestrel May 16, 2020
@ffMathy
Copy link
Owner

ffMathy commented May 16, 2020

Looks good to me.

Also, totally starstruck that @davidfowl visited my repo to review 🤩

@davidfowl got any final comments on the review fixes before I merge this?

Copy link

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants