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

Lua OCSP stapling #5133

Merged
merged 1 commit into from
Apr 17, 2020
Merged

Lua OCSP stapling #5133

merged 1 commit into from
Apr 17, 2020

Conversation

ElvinEfendi
Copy link
Member

@ElvinEfendi ElvinEfendi commented Feb 19, 2020

For #4758

In order to avoid Nginx reload we have moved to dynamically handling TLS certificate serving using Lua a while ago. That also meant things like ssl_stapling directives became useless. This PR implements alternative to Nginx's ssl_stapling using Lua.

This is bare minimum implementation, expect a lot of rough edges.

The implementation tries to follow advice from https://gist.github.com/sleevi/5efe9ef98961ecfb4da8, but it is not even close to all the best practices mentioned there.

Another important shortcoming of this implementation to keep in mind is that Lua OCSP API does not provide API for thisUpdate and nextUpdate, therefore we are just caching responses for 3 days. This might and might not be acceptable by some users.

Also keep in mind that our implementation deos its best at stapling, vs vanilla Nginx staples only when the response is "good".

With all these in consideration, give it a try and let us know what can be improved, even better improve it yourself - patches are always welcome.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 19, 2020
@ElvinEfendi
Copy link
Member Author

Maybe it's worth to check how Nginx implements OCSP stapling.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 19, 2020
@codecov-io
Copy link

codecov-io commented Feb 26, 2020

Codecov Report

Merging #5133 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5133   +/-   ##
=======================================
  Coverage   58.64%   58.64%           
=======================================
  Files          88       88           
  Lines        6913     6913           
=======================================
  Hits         4054     4054           
  Misses       2414     2414           
  Partials      445      445           
Impacted Files Coverage Δ
internal/ingress/controller/template/configmap.go 76.41% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42b3a1e...1dab12f. Read the comment docs.

@aledbf
Copy link
Member

aledbf commented Feb 26, 2020

@ElvinEfendi please rebase

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 23, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 16, 2020
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Apr 16, 2020

@ElvinEfendi: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-ingress-nginx-chart-lint abad391644e398d7084c05e08fa1b409c6f3c218 link /test pull-ingress-nginx-chart-lint

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@ElvinEfendi ElvinEfendi changed the title [WIP] Lua OCSP stapling Lua OCSP stapling Apr 17, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 17, 2020
@aledbf
Copy link
Member

aledbf commented Apr 17, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 17, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 6e8c68d into kubernetes:master Apr 17, 2020
@ElvinEfendi ElvinEfendi deleted the lua-ocsp-stapling branch April 17, 2020 02:57
@logopk
Copy link

logopk commented Nov 3, 2021

I would like to reopen this:
Apparently the config works, but OCSP responses for revoked certs fail.

Today I wanted to switch certificates from RSA to ECC and revoked the RSA certs prior to installing the ECCs.

My OCSP-responder clearly indicated that the cert was revoked, but the browser, curl and openssl were happy.
So I first thought the config was wrong. But the option was still enabled.

So I looked at the logfiles and found the following line:

2021/11/03 16:54:31 [notice] 184#184: *10735 [lua] certificate.lua:171: fetch_and_cache_ocsp_response(): OCSP response validation failed: certificate status "revoked" in the OCSP response, context: ngx.timer, client: 192.168.1.19, server: 0.0.0.0:443

and openssl output was:

> openssl s_client -servername myserver.example.com -connect myserver.example.com:443 -status ' | grep"OCSP"
...
OCSP response: no response sent

My system is:

😄  minikube v1.23.2 auf Darwin 11.6.1
✨  Using the vmware driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing vmware VM for "minikube" ...
🐳  Vorbereiten von Kubernetes v1.22.2 auf Docker 20.10.8.../ 
\ 
/ 

🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
    ▪ Using image k8s.gcr.io/metrics-server/metrics-server:v0.4.2
    ▪ Using image kubernetesui/dashboard:v2.3.1
    ▪ Using image k8s.gcr.io/ingress-nginx/controller:v1.0.0-beta.3
    ▪ Using image kubernetesui/metrics-scraper:v1.0.7
    ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
    ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
🔎  Verifying ingress addon...
🌟  Enabled addons: storage-provisioner, ingress, metrics-server, default-storageclass, dashboard
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
configmap/ingress-nginx-controller configured

@logopk
Copy link

logopk commented Nov 3, 2021

I just read the comment @ElvinEfendi at https://github.com/kubernetes/ingress-nginx/blob/30809c066cd027079cbb32dccc8a101d6fbffdcb/rootfs/etc/nginx/lua/certificate.lua
Lines 149ff

Well: "revoked" should be handled, as this is the purpose of OCSP in the first place :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants