-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Make it easier to add certs to the extra store #29828
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
RevocationMode = X509RevocationMode.NoCheck | ||
}, Certificates.SignedClient); | ||
|
||
using var server = host.GetTestServer(); |
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.
@bartonjs I added the new ExtraStore property but its not clear to me how exactly do I test that they are working as intended? They are being added to the chain's property now but I'm not sure how to measure the effect externally, is this just additional certs that developers would use themselves?
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 don't know where all the chain can appear, so I'll stick to a high level test concept:
- Have a 3+ certificate chain which does not come from a public trust system and does not use Authority Information Access (AIA) chaining (either statically generated or on the fly using the CertificateRequest API).
- Add the root to the custom trust store (and set the mode to CustomRootTrust), add all of the intermediates to AdditionalChainCertificates.
- When the chain builds, it builds successfully.
- Bonus test, first do it without adding the certs to AdditionalChainCertificates and see that the chain can't be built.
- Other bonus test, add the root to AdditionalChainCertificates and don't add it to custom trust. The chain should have all of the certificates but be untrusted.
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.
Thanks @bartonjs that's exactly what I was hoping for, a high level overview. The bonus test is actually what this current test is doing, (and it fails). So one thing is we don't actually expose the ChainPolicy that we use to validate externally. So there's no easy way to do anything with the ExtraStore since we don't pass the X509Chain we build to any of our events.
See
aspnetcore/src/Security/Authentication/Certificate/src/CertificateAuthenticationHandler.cs
Line 125 in 39dad31
var chainPolicy = BuildChainPolicy(clientCertificate); |
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.
Cool updated and added a test for a positive case and a rejected/forbidden one.
src/Security/Authentication/Certificate/src/CertificateAuthenticationHandler.cs
Show resolved
Hide resolved
@aalsamoht FYI |
Thanks for your help @bartonjs ! |
Fixes #29679