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

Update Documentation for Client-Cert Authentication misleading #10687 #10705

Merged
merged 7 commits into from
Dec 9, 2023

Conversation

clauspruefer
Copy link
Contributor

@clauspruefer clauspruefer commented Nov 30, 2023

Update / restructure "Client Cert Authentication" Documentation sub-section

Types of changes

  • Update client-auth documentation containing all needed information on one page / sub-sections

Which issue/s this PR fixes

fixes #10687

How Has This Been Tested?

Already tested.

Checklist:

  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added unit and/or e2e tests to cover my changes.
  • All new and existing tests passed.

Viewable Documentation / Page:

https://github.com/clauspruefer/ingress-nginx/tree/main/docs/examples/auth/client-certs

Update / restructure "Client Cert Authentication" Documentation sub-section
Copy link

netlify bot commented Nov 30, 2023

Deploy Preview for kubernetes-ingress-nginx ready!

Name Link
🔨 Latest commit 17b8830
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/656eff31691db90008e14b9d
😎 Deploy Preview https://deploy-preview-10705--kubernetes-ingress-nginx.netlify.app/examples/auth/client-certs
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 30, 2023
Copy link

linux-foundation-easycla bot commented Nov 30, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Welcome @clauspruefer!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added area/docs needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 30, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @clauspruefer. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot requested a review from cpanato November 30, 2023 02:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 30, 2023
@clauspruefer clauspruefer marked this pull request as draft December 2, 2023 13:45
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 2, 2023
@clauspruefer clauspruefer marked this pull request as ready for review December 4, 2023 17:47
@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 Dec 4, 2023
@k8s-ci-robot k8s-ci-robot requested a review from strongjz December 4, 2023 17:47
Add openssl subjectAltName and remark for future releases.
Moved subjectAltName to new topic "Remarks", i think it is not annotation / ingress related
@clauspruefer
Copy link
Contributor Author

Sorry, currently the client-auth doc did not contain wrong information, it just was a bit misleading.
I updated to correct information.

@clauspruefer clauspruefer changed the title Fix Documentation for Client-Cert Authentication contains wrong information #10687 Update Documentation for Client-Cert Authentication misleading #10687 Dec 4, 2023
@clauspruefer
Copy link
Contributor Author

clauspruefer commented Dec 5, 2023

Currently verified working in End2End test (including whitelist filtering):

Cert Generation

kubectl -n spx-test create secret generic ca-spxcomserver-spx-webui-test-tls-cert --from-file=ca.crt=./ca-cert.pem --from-file=tls.crt=./server-cert.pem --from-file=tls.key=./server-key.pem

kubectl create secret tls spxcomserver-spx-webui-test-tls-cert --cert ./server-cert.pem --key ./server-key.pem

Ingress Definition

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream: "true"
    nginx.ingress.kubernetes.io/auth-tls-secret: spx-test/ca-spxcomserver-spx-webui-test-tls-cert
    nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
    nginx.ingress.kubernetes.io/whitelist-source-range: x.x.x.x/32
  creationTimestamp: "2023-11-30T12:53:58Z"
  generation: 1
  name: spxcomserver-spx-webui-test-tls-ingress
  namespace: spx-test
  resourceVersion: "4939686"
  uid: 98d5a78c-2b25-4424-b0eb-9c73cb63f795
spec:
  ingressClassName: class-ingress-webui-test
  rules:
  - host: xyz.click-it.online
    http:
      paths:
      - backend:
          service:
            name: spxcomserver-spx-webui-test-svc
            port:
              number: 80
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - spx-webui-test.click-it.online
    secretName: spxcomserver-spx-webui-test-tls-cert
status:
  loadBalancer:
    ingress:
    - ip: x.x.x.x

Client is Mozilla Firefox with imported .p12 (CA-cert, ClientCert, ClientKey).

@clauspruefer
Copy link
Contributor Author

clauspruefer commented Dec 9, 2023

Hi, this PR seems to be stuck. Just a few words why this all came up (important!).

Our company runs a project where Client-Cert-Authentication is required. Our developers are expirienced with Apache-TLS, Client-Cert Authentication, also NGINX configurations which use TLS Client-Cert-Auth have been setup lately.

Now we switched to Kubernetes and ingress-nginx which relies on kubectl secret. The secret certificate handling and especially the ingress-nginx / .yaml integration seems quite unhandy if you have used the very simple Apache2 configuration, where you just have to link:

  1. CA-Certificate
  2. Server Certificate
  3. Server Private Key / eventually Passphrase if encrypted

I think this is where the confusion starts with kubectl secret. The multiple import options for secrets (generic and TLS) and the dividing of ingress-nginx into "annotations" AND TLS configuration.

Especially if you are expirienced with SSL / TLS you always include a CA-Certificate for the "Transport" Layer in a Server-Configuration. Very seldom you use just Server-Cert and Server-Key without CA-Certificate.

But exactly this is pointed out in the Kubernetes-Documentaion importing TLS with kubectl create secret tls spxcomserver-spx-webui-test-tls-cert --cert ./server-cert.pem --key ./server-key.pem.

The way by doing kubectl -n spx-test create secret generic ca-spxcomserver-spx-webui-test-tls-cert --from-file=ca.crt=./ca-cert.pem --from-file=tls.crt=./server-cert.pem --from-file=tls.key=./server-key.pem on command line is a VERY-UNUSUAL (double =tls.crt=filename).

So the implementation in our Python-Kubernetes-Installer failed because the double = assignment (which also seems like a workaround of the Kubernetes OOP Backend-Handling). So our developers thought that the ingress-nginx behaviour / documentation was broken because the double = assignment :(

So my intention was to setup a clear documentation how to link certificates to ingress-nginx / Kubernetes with this PR (please check the rendered output in my fork, i added the link to the PR description).

In my oppinion the only thing which needs ajustment is to check, if you can link the same secret-reference in the following config:

nginx.ingress.kubernetes.io/auth-tls-secret: namespace/secret-ref

and (config without namespace, secret needs to be inside correct namespace)

tls:
- hosts:
  - domain.com
  secretName: secret-ref

And afterwards emphasis the cert-import ALWAYS by following command:

kubectl -n spx-test create secret generic ca-spxcomserver-spx-webui-test-tls-cert --from-file=ca.crt=./ca-cert.pem --from-file=tls.crt=./server-cert.pem --from-file=tls.key=./server-key.pem

@strongjz I think this is really important for non-tls-experts and global internet-security should use such features more often, so please consider using my adapted documentation.

@longwuyuan
Copy link
Contributor

@clauspruefer I could not find the key "ca.crt" type info in the help for the kubectl create secret command. So this information is a super helpful improvement to the docs. Thanks for the contribution.

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 9, 2023
@longwuyuan
Copy link
Contributor

@clauspruefer I would even recommend that you submit a PR in the other sig that maintains the kubectl binary, to add the examples you have shown here.

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clauspruefer, longwuyuan

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 9, 2023
@k8s-ci-robot k8s-ci-robot merged commit 14d8be4 into kubernetes:main Dec 9, 2023
5 checks passed
@clauspruefer
Copy link
Contributor Author

@clauspruefer I would even recommend that you submit a PR in the other sig that maintains the kubectl binary, to add the examples you have shown here.

/lgtm

Thanx for the feedback :). I will open PR asap. TLS/SSL needs to be implemented correctly to increase global internet security.

@longwuyuan
Copy link
Contributor

True. In this case though since those key:value pairs allowed for cert, chain and the key, it seems the implementation exists but precise docs for including 3 hashes is not common knowledge.

Maybe people were concatenating cert+chain in a single file (I may have tried that too once or twice, not sure).

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. area/docs 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. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Documentation for Client-Cert Authentication misleading
3 participants