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

Setup TLS with CA Cert for vsphere cloud provider #64758

Merged
merged 19 commits into from
Jun 30, 2018
Merged

Setup TLS with CA Cert for vsphere cloud provider #64758

merged 19 commits into from
Jun 30, 2018

Conversation

mariantalla
Copy link
Contributor

  • Extend config to take a path to a CA Certificate
  • Use the CA Cert when establishing a connection with the SOAP client

Testing
We provide certs and keys for tests as fixtures, vclib/fixtures.
Those were created (and can be regenerated) using vclib/fixtures/createCerts.sh.

At the moment it's possible to configure a CA path and at the same time allow insecure
communication between vsphere cloud provider and vcenter. This may
change in the future; we might opt for overwriting the insecure
communication if a CA is configured / log and transparently pass the
arguments to the vcenter command / other. To be discussed.

At the moment the CA is a global level configuration. In other
words, all vcenter servers need to use certificates signed by the same
CA. There might be use cases for different CA per vcenter server; to be
discussed.

What this PR does / why we need it:
This PR adds the option of configuring a trusted CA for the communication between the vsphere cloud provider and the vcenter control plane.

Which issue(s) this PR fixes:
Fixes #64222

Special notes for your reviewer:

Release note:

- Can configure the vsphere cloud provider with a trusted Root-CA

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 5, 2018
@k8s-ci-robot k8s-ci-robot requested review from j3ffml and wojtek-t June 5, 2018 10:33
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 5, 2018
@hoegaarden
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 5, 2018
@mariantalla
Copy link
Contributor Author

@wgliang Thanks for the feedback. For some reason your comments disappeared when we pushed new commits.

Some points you brought up that should be hopefully sorted now:

  • LICENCE for test files added
  • comments that document functions configFromSim and configFromSimWithTLS are now accurate

Remaining points that you brought up:

  • More test cases: what would you like to see covered which is not already?
  • TableDrivenTests: we think that it will introduce more overhead than help at the moment, but will certainly consider it once we have more test cases (we still have work to do on this PR).
  • vclib_test vs vclib package for tests: We generally tend to lean towards blackbox testing, so we force ourselves to not touch internals of packages. Thus the package vclib_test. What were your thoughts on putting the tests in the same package as the source?

@wgliang
Copy link
Contributor

wgliang commented Jun 5, 2018

@mariantalla
I'm very sorry, because I didn't see WIP at first, you can change it to the more obvious [WIP].

@mariantalla mariantalla changed the title wip - Setup TLS with CA Cert for vsphere cloud provider [WIP] Setup TLS with CA Cert for vsphere cloud provider Jun 5, 2018
@mariantalla
Copy link
Contributor Author

@wgliang Thanks, changed the title! Please keep commenting even though it's still in progress. Would love to hear your thoughts on test cases and packages in particular.

@wgliang
Copy link
Contributor

wgliang commented Jun 5, 2018

@mariantalla
Of course, thank you very much and willingly.

@hoegaarden
Copy link
Contributor

/test pull-kubernetes-node-e2e

Maria Ntalla added 13 commits June 8, 2018 12:00
- Extend config to take a path to a CA Certificate
- Use the CA Cert when establishing a connection with the SOAP client

Testing
We provide certs and keys for tests as fixtures, `vclib/fixtures`.
Those were created (and can be regenerated) using `vclib/fixtures/createCerts.sh`.

At the moment it's possible to configure a CA path and at the same time allow insecure
communication between vsphere cloud provider and vcenter. This may
change in the future; we might opt for overwriting the insecure
communication if a CA is configured / log and transparently pass the
arguments to the vcenter command / other. To be discussed.

At the moment the CA is a global level configuration. In other
words, all vcenter servers need to use certificates signed by the same
CA. There might be use cases for different CA per vcenter server; to be
discussed.
./hack/update-bazel.sh
Also remove comments that are not useful anymore.
This will help with bazel tests, which seem to use a different working
directory from local test runs.
... and rename `InvalidCaCertPath` to `InvalidCertPath`.
@hoegaarden
Copy link
Contributor

PTAL

@dougm
Copy link
Member

dougm commented Jun 24, 2018

Thanks @mariantalla @hoegaarden lgtm

/approve

@@ -175,3 +210,25 @@ func (connection *VSphereConnection) UpdateCredentials(username string, password
connection.Username = username
connection.Password = password
}

func normalizeThumbprint(original string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case that would require this normalization?

t.Fatalf("Cannot add CA to CAPool")
}

server := httptest.NewUnstartedServer(http.HandlerFunc(handler))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if len(server.TLS.Certificates) < 1 || len(server.TLS.Certificates[0].Certificate) < 1 {
t.Fatal("Expected server.TLS.Certificates not to be empty")
}
x509LeafCert := server.TLS.Certificates[0].Certificate[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without simulator, you can use HostCertificateInfo.FromCertificate https://github.com/vmware/govmomi/blob/b3251638696a6f4ac905fe904091e9840982c602/simulator/simulator_test.go#L353-L358

Maybe this also avoids the need for the normalization function?

@hoegaarden
Copy link
Contributor

@dougm @divyenpatel @wgliang Is there anything left to do for us to get the lgtm -- i think that's missing to get this merged, isn't it?

@dougm
Copy link
Member

dougm commented Jun 28, 2018

@divyenpatel approved via review, but we need his '/lgtm' to add the label.

@divyenpatel
Copy link
Member

/assign @divyenpatel

@divyenpatel
Copy link
Member

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: divyenpatel, dougm, mariantalla

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 Jun 28, 2018
@dougm
Copy link
Member

dougm commented Jun 28, 2018

/test pull-kubernetes-kubemark-e2e-gce-big

@hoegaarden
Copy link
Contributor

/test pull-kubernetes-e2e-gce

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

2 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@mariantalla
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

3 similar comments
@hoegaarden
Copy link
Contributor

/test pull-kubernetes-e2e-gce

@hoegaarden
Copy link
Contributor

/test pull-kubernetes-e2e-gce

@hoegaarden
Copy link
Contributor

/test pull-kubernetes-e2e-gce

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

2 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 64243d4 into kubernetes:master Jun 30, 2018
@marpaia
Copy link
Contributor

marpaia commented Jul 2, 2018

/sig vmware

@k8s-ci-robot k8s-ci-robot added the area/provider/vmware Issues or PRs related to vmware provider label Jul 2, 2018
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/provider/vmware Issues or PRs related to vmware provider 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vSphere Cloud Provider: add vCenter certificate verification options
9 participants