ingress-nginx icon indicating copy to clipboard operation
ingress-nginx copied to clipboard

Attempt to Assign Non-Default Cert to Nginx Server by Host

Open GabrielAlacchi opened this issue 3 years ago • 8 comments

What this PR does / why we need it:

Made a draft PR to demonstrate a possible fix for the discussion in #9040

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] CVE Report (Scanner found CVE and adding report)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation only

Which issue/s this PR fixes

fixes #9040

How Has This Been Tested?

[ ] Working on unit tests + e2e tests

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I've read the CONTRIBUTION guide
  • [ ] I have added unit and/or e2e tests to cover my changes.
  • [ ] All new and existing tests passed.
  • [ ] Added Release Notes.

Does my pull request need a release note?

Any user-visible or operator-visible change qualifies for a release note. This could be a:

  • CLI change
  • API change
  • UI change
  • configuration schema change
  • behavioral change
  • change in non-functional attributes such as efficiency or availability, availability of a new platform
  • a warning about a deprecation
  • fix of a previous Known Issue
  • fix of a vulnerability (CVE)

No release notes are required for changes to the following:

  • Tests
  • Build infrastructure
  • Fixes for unreleased bugs

For more tips on writing good release notes, check out the Release Notes Handbook

PLACE RELEASE NOTES HERE 

GabrielAlacchi avatar Sep 12 '22 15:09 GabrielAlacchi

CLA Not Signed

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GabrielAlacchi Once this PR has been reviewed and has the lgtm label, please assign tao12345666333 for approval by writing /assign @tao12345666333 in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 avatar Sep 12 '22 15:09 k8s-ci-robot

@GabrielAlacchi: 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 avatar Sep 12 '22 15:09 k8s-ci-robot

Welcome @GabrielAlacchi!

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. :smiley:

k8s-ci-robot avatar Sep 12 '22 15:09 k8s-ci-robot

Hi @GabrielAlacchi. 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 avatar Sep 12 '22 15:09 k8s-ci-robot

I still don't see how ;

  • first you configure a ingress resource with the field ingress.spec.tls.secretName having secretName value, that contains invalid certificate
  • And then make the ingress-nginx-controller check the internals of ;
    • all the certificates
    • in all the other secrets
    • configured in all the ingress resources
    • in all the namespaces of the cluster
  • and guarantee 100% certainity to respond to the https request, with a valid certificate

But I will wait for other comments. I am confused

longwuyuan avatar Sep 12 '22 16:09 longwuyuan

This works on my local dev environment using the repro steps I created here https://github.com/GabrielAlacchi/IngressNginxCertRepro. Will follow up with test coverage later on and mark as ready for review.

GabrielAlacchi avatar Sep 12 '22 18:09 GabrielAlacchi

Thanks. I saw your approach. And then tried to clarify a simple question. I will try to re-phrase here.

Your proposal is basically allowing a user to configure a invalid value for the field ingress.spec.tls.secretName . I don't think the entire user base or the developers will want to allow that kind of behavior. So lets wait for comments.

Additionally, the reason to check the configured secretName is obvious and the feature to present the default fake cert as a fallback is also obvious. But a inspection of all secrets of type tls is intrusive to begin with and downright violates namespace security, if ingress resource in one namespace can trigger inspection of secrets of type tls from another namespace, or even another secret of type tls, even in the same namespace. If the secrets belong to 2 different Orgs, then neither would appreciate the other Org's ingress resource, inspecting its secret.

Please elaborate, how will you handle a situation where a user configures a invalid value in the secretName field and there is no valid cert in the entire cluster for the hostname header received in request.

These are my opinions and I could be completely wrong as I am not a developer. So lets wait for comments.

longwuyuan avatar Sep 12 '22 20:09 longwuyuan

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Dec 11 '22 21:12 k8s-triage-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GabrielAlacchi Once this PR has been reviewed and has the lgtm label, please assign strongjz for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 avatar Aug 14 '23 19:08 k8s-ci-robot

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
Latest commit 3ff38ad65958b35942648f1415527f4f4fe994e0
Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/64da7a3970f66400080e1f1a

netlify[bot] avatar Aug 14 '23 19:08 netlify[bot]

/close

No recent activity on this PR, please feel free to reopen it or open a new one if this is still something to be fixed

rikatz avatar Feb 27 '24 12:02 rikatz

@rikatz: Closed this PR.

In response to this:

/close

No recent activity on this PR, please feel free to reopen it or open a new one if this is still something to be fixed

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 avatar Feb 27 '24 12:02 k8s-ci-robot