-
Notifications
You must be signed in to change notification settings - Fork 8.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
Lua land OCSP stapling improvements #5397
Comments
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Hi @ElvinEfendi I am using I am also using cert-manager and use Everything worked as expected at the beginning, cert-manager can generate certificate for my domain and ingress-controller can fetch OCSP Response and do the OCSP Stapling for my domain. The problem is, when cert-manager renew the certificate, ingress-controller still using the old OCSP Response. Let's say the certificate's Validity is
I guess that would cause inconsistence between the certificate and OCSP Response?
From what I get on hand, Browsers and iOS Native Apps ignore that inconsistence, but Android would complain that Maybe ingress-controller should expire the old OCSP Response when a new certificate is generated? Or it's cert-manager's duty to notify the renewal of certificate? I will try to understand |
/remove-lifecycle rotten |
@wenzong thanks for the report. I think that's because we use k8s secret's UID as a cache key. And when cert-manager updates the certificate, the corresponding secret's cache is remains unchanged. If you traceback
I think the fix would be to use certificate's serial number as the cache key. Or if Lua does not expose any API to get serial number, we can also simply md5 hash the certificate payload itself and use it as a cache key. I'd be happy to guide you if you want to take a stab at this. |
Thanks for your reply. I see, so ingress-controller watches secret's changes, and post certificate information via
Lua receive it in
ngx.shared.DICT
There are three relationships:
Coming request will use hostname(server name) to find certificate and I guess better change UID to something worldwide unique for one certificate? Serial number is only unique for one specific CA. The poster suggest either use I noticed that there is a PemSHA ingress-nginx/internal/ingress/sslcert.go Line 52 in 87aa96b
UID , then the relationship is like:
Any thought? |
The problem with this is that we will pollute -- Maybe in
uid under consideration?
|
You are right, do expire cache is more reasonable. |
@ElvinEfendi I just rethink the implementation and realized that there is a potential concurrency problem. So in
Since the two steps are not atomic operation, there is a small chance that some nginx worker missed the cache and read the old certificate, then fetch and cache the old ocsp_response again. I will try to solve it tomorrow. The PR is #6200 |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Since #5133 and #5387 ingress-nginx supports OCSP stapling (to replace vanilla Nginx's SSL stapling).
In this issue I'd like us to collect user feedback and track list of things to do to improve the OCSP support further:
fetch_and_cache_ocsp_response
to avoid a scenario where multiple Nginx workers send request to OCSP responder for the same certificatefetch_and_cache_ocsp_response
. We might want to differentiate negative caching between validation failures and HTTP request failures - I think each should be handled differently. HTTP request failures is likely to be intermittent and should be cached for short term, while validation failures are long term and should be negatively cached for longer. We can even go further and differentiate between validation failure errors - for example validation fails when status is "revoked", in these cases we should cache forever right? In case status is "unauthorized" though I'm not sure - maybe we can cache forever again because it means certificate is borked and has an incorrect OCSP responder URL?ssl_stapling_verify
and always passesOCSP_NOVERIFY
flag when callingOCSP_basic_verify
. There's also a test case for that: https://github.com/openresty/lua-resty-core/blob/1bd74f8f502a9dc0a7099110d0ee184187698d01/t/ocsp.t#L1120. https://www.openssl.org/docs/man1.1.1/man3/OCSP_basic_verify.html explains this further. My understanding is by passingOCSP_NOVERIFY
we effectively skip verification of certificate that was used to sign the OCSP response, in other words OCSP response could have been served by an attacker and we would not know. But is this really an issue for OCSP stapling? Browser should do full verification upon receiving the response no?The text was updated successfully, but these errors were encountered: