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

Restore compatibility in specifying custom CAs by using Go client #1735

Merged
merged 3 commits into from May 12, 2021

Conversation

maya-r
Copy link
Contributor

@maya-r maya-r commented Apr 4, 2021

This restores support for the following scenarios:

  • Now the system certs are considered as valid when a custom CA is used.
  • The custom CA will be accepted regardless of the key value used in the configmap.

Add a test for the second scenario.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1946100

Special notes for your reviewer:
The scenario of system-wide certs is not tested because it requires using an external server.

Release note:

Restore compatibility: users are once again able to specify custom CAs for use in import in names other than tls.crt

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Apr 4, 2021
@maya-r
Copy link
Contributor Author

maya-r commented Apr 4, 2021

Needs tests.

@awels
Copy link
Member

awels commented Apr 5, 2021

Also needs to fix the unit tests and imageio functional tests that are now broken.

Copy link
Member

@awels awels left a comment

Choose a reason for hiding this comment

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

So why not use x509.SystemCertPool to create a cert pool, and then append the certs from the other directories to it. Then pass this cert pool to the http client somehow instead of writing everything to a file somewhere, and re-reading it into a cert pool.

// CURL either supports a hashed-directory of certificates or a single file certificate.
// Create a single file containing all our certificates.
func createCAFile(certDir string) error {
systemCertDir := "/etc/pki/tls/certs/"
Copy link
Member

Choose a reason for hiding this comment

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

Why are we hard coding some path that may or may not exist in various variations of linux. That is why we used x509.SystemCertPool, so we don't have to care about the paths of the system certs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mainly want to create a file later to be used by nbdkit curl plugin, I didn't find a way to go from a certpool to a file

// append the user-provided trusted CA certificates bundle when making egress connections using proxy
if files, err := ioutil.ReadDir(common.ImporterProxyCertDir); err == nil {
for dir := range certDirs {
files, err := ioutil.ReadDir(certDir)
Copy link
Member

Choose a reason for hiding this comment

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

Why are looping over the different dirs, and then only reading certDir, I am assuming you want

files, err := ioutils.ReadDir(dir)

@maya-r
Copy link
Contributor Author

maya-r commented Apr 8, 2021

I went back because I had trouble making the more complex patch work.
We used to use the Go client before the nbdkit changes - the catch-all before used to be "use scratch space" and it stopped being that.

@maya-r
Copy link
Contributor Author

maya-r commented Apr 8, 2021

oops, a rebase accident... I wanted to test that the test fails before the fix, and accidentally pushed that version :-)

@maya-r
Copy link
Contributor Author

maya-r commented Apr 8, 2021

/test pull-cdi-unit-test
doesn't seem to fail locally. wondering if this is a time-based flake.

Comment on lines 93 to 94
for _, value := range srcCm.Data {
certBytes = value
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the iteration? It gets the last item, so let's just to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure about the idiomatic way to do it, there's usually only going to be one element here, I could add a break for clarity.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 21, 2021
@kubevirt-bot kubevirt-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 21, 2021
This restores support for the following scenarios:
- Now the system certs are considered as valid when a custom
CA is used.
- The custom CA will be accepted regardless of the key value
used in the configmap.

Add a test for the second scenario.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
Signed-off-by: Maya Rashish <mrashish@redhat.com>
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2021
@tomob
Copy link
Contributor

tomob commented Apr 26, 2021

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 26, 2021
@aglitke
Copy link
Member

aglitke commented Apr 26, 2021

/retest

@maya-r
Copy link
Contributor Author

maya-r commented Apr 29, 2021

/test pull-containerized-data-importer-e2e-k8s-1.17-ceph

@maya-r maya-r changed the title Restore compatibility in specifying custom CAs Restore compatibility in specifying custom CAs by using Go client May 2, 2021
@maya-r
Copy link
Contributor Author

maya-r commented May 4, 2021

/cherry-pick release-v1.34

@kubevirt-bot
Copy link
Contributor

@maya-r: once the present PR merges, I will cherry-pick it on top of release-v1.34 in a new PR and assign it to you.

In response to this:

/cherry-pick release-v1.34

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.

@maya-r
Copy link
Contributor Author

maya-r commented May 6, 2021

ping @awels

@awels
Copy link
Member

awels commented May 6, 2021

So basically this is reverting some of the usage of nbdkit because we can't get it to properly read the certs?

@maya-r
Copy link
Contributor Author

maya-r commented May 9, 2021

It's switching the custom cert case to use the Go client for downloading, so we have the same behaviour as we did before.
Nbdkit is still used later on.

Had a hard time replicating the cert behaviour with nbdkit (if a cert is specified, global certs are still accepted. if multiple certs are specified, they are all accepted).

Signed-off-by: Maya Rashish <mrashish@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label May 9, 2021
@awels
Copy link
Member

awels commented May 10, 2021

/test pull-containerized-data-importer-e2e-k8s-1.17-ceph

@awels
Copy link
Member

awels commented May 10, 2021

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2021
@brybacki
Copy link
Contributor

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label May 12, 2021
@kubevirt-bot kubevirt-bot merged commit c735fd5 into kubevirt:main May 12, 2021
@kubevirt-bot
Copy link
Contributor

@maya-r: new pull request created: #1787

In response to this:

/cherry-pick release-v1.34

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.

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm 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/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants