-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add an OCSP responder to Vault's PKI plugin #16723
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.
Some thoughts to get discussions started :-)
Overall, I think it is well written and tested. Just some behavior discussions below that I wonder if we want to change?
|
||
info.ocspStatus = ocsp.Revoked | ||
info.revocationTimeUTC = &revEntry.RevocationTimeUTC | ||
info.issuerID = revEntry.CertificateIssuer // This might be empty if the CRL hasn't been rebuilt |
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 I'm kinda of two minds here.
If the CRL is never rebuilt, we're stuck always incurring the iteration over all issuers down in lookupOcspIssuer
. This increases request time, and isn't strictly correct (w.r.t. if the issuer hash/... doesn't match as expected).
However, if the CRL is eventually rebuilt, we'd be doing extra work for potentially no reason.
My 2c., but I'd kinda prefer that we refactor the CRL rebuilding logic so that it can be reused here: https://github.com/hashicorp/vault/blob/main/builtin/logical/pki/crl_util.go#L523-L567
That way, if there is no issuer entry, we can help future lookups of the same cert and avoid recomputing the value each time (when CRL isn't used).
Then, down below, in the lookupIsssuerIds
, we only need to compare the expected issuer's hashes against the actual issuer ID's backing issuer's hashes (since they're correct up to isomorphism) and if they mismatch, we can give a proper error (malformed request probably).
The reason for this is, IMO, I'd love to see a standalone (CRL disabled), performant OCSP server. If we require the CRL to be rebuilt to pick up new issuer revocations, I think that's less than ideal.
Alternatively (or additionally) we could also move issuer association to revocation time if we wanted?
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'm going to take another look tomorrow, but this hard parts here (caching/locking/figuring out how to pipe in the OCSP requests), are looking really good. I do have some nits, and would love to fool around with this a bit more before approving.
- pki.mdx doc update - parens around logical.go comment to indicate DER encoded request is related to OCSP and not the snapshots - Use AllIssuers instead of writing them all out - Drop zero initialization of crl config's Disable flag if not present - Upgrade issuer on the fly instead of an initial migration
ad2e82e
to
2296498
Compare
Updated all feedback, I did not change the atomic boolean/setOcspStatus stuff as there is another PR that will update that. Also this has been rebased on top of the latest main branch. @cipherboy @kitography this should be ready for re-review! |
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.
Finally got around to looking through the tests, I think this makes sense and looks good!
I think there's one interesting inline question about forwarding, but the rest are nits. :-)
18fc058
to
954cafd
Compare
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 am well into nits, these tests are super cool.
|
||
if matches { | ||
if !issuer.Usage.HasUsage(OCSPSigningUsage) { | ||
// We found the correct issuer, but it's not allowed to sign the |
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.
Is it not possible for there to be more than one matching issuer here? (Same name, key, different expiry/certificate usages?)
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.
Hmm, this is a good point. I'd probably suggest addressing it in a follow-up though, so as not to block too much.
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.
Yup noted, I'll address this feedback in a different PR, but great catch @kitography!
- Leverage ocsp response constant - Remove duplicate errors regarding unknown issuers
@@ -0,0 +1,4 @@ | |||
```release-note:feature |
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.
👋🏻 This changelog entry isn't correctly formatted for new features.
**OCSP Responder**: <text>
You can check out the 1.11 changelog for a reference, and there's also a wiki page about this. Could you please update this file on main so that it formats correctly in the final version of the 1.12 changelog?
Add an OCSP responder to Vault's PKI plugin. This is a simplistic responder that at the moment will only accept a single query at a time with no support for any extensions defined within RFC 6960, mainly due to the limitations in Go's OCSP libraries.
An end-user will be able to disable the responder through the existing
config/crl
endpoint with the newly added keyocsp_disable
. The responder will be enabled by default, if the key is set to true to disable the responder, an OCSP response ofUnauthorized
will be returned to the caller.