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

🌱 Add support for PKCS8 private keys in CA certs #3175

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

maelk
Copy link
Contributor

@maelk maelk commented Jun 10, 2020

What this PR does / why we need it:

This PR adds support for PKCS8 formatted CA private key, to prevent failure when a user provides his own CA key using the commands from the CAPI book : https://cluster-api.sigs.k8s.io/tasks/certs/using-custom-certificates.html
A setup with those commands would otherwise fail.

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 10, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @maelk. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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 added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 10, 2020
@maelk
Copy link
Contributor Author

maelk commented Jun 10, 2020

/assign @detiber

@fabriziopandini
Copy link
Member

/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 Jun 10, 2020
util/certs/certs.go Outdated Show resolved Hide resolved
@maelk maelk force-pushed the pkcs8-mael branch 3 times, most recently from ff755e3 to 9c766cd Compare June 12, 2020 07:33
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 12, 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 Jun 12, 2020
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
util/certs/types.go Outdated Show resolved Hide resolved
util/kubeconfig/kubeconfig.go Outdated Show resolved Hide resolved
util/certs/certs.go Outdated Show resolved Hide resolved
util/certs/types.go Outdated Show resolved Hide resolved
util/kubeconfig/kubeconfig.go Outdated Show resolved Hide resolved
@benmoss
Copy link

benmoss commented Jun 15, 2020

/approve cancel

not enough coffee this morning

@maelk
Copy link
Contributor Author

maelk commented Jun 16, 2020

@detiber and @benmoss How do you propose to proceed with this change ? Should I change the APIs, and in that case, how do we ensure that go-apidiff would pass ? or should I try to keep the signature exactly the same for the existing functions ?

The failures were here : https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/3175/pull-cluster-api-apidiff/1271334352977924096

@benmoss
Copy link

benmoss commented Jun 16, 2020

go-apidiff isn't a merge-blocking job. I'll defer to @detiber for when we ignore it though, as I still don't entirely understand when it's okay 😄

@benmoss
Copy link

benmoss commented Jun 16, 2020

OK, I think I finally grok why you added the extra functions. I think @detiber is correct, that if you change all the *rsa.PrivateKeys to crypto.PrivateKeys, the signatures will remain valid for all the current use-cases, since that interface is a superset. That will still make the apidiff job fail, but we can ignore it I believe.

Maybe we want to use crypto.Signer actually instead since it is what x509.CreateCertificate depends on.

@maelk maelk force-pushed the pkcs8-mael branch 3 times, most recently from b7785b3 to 2660d94 Compare June 16, 2020 17:41
@benmoss
Copy link

benmoss commented Jun 16, 2020

Looks like another flake I added to my issue here #3197

/retest

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

This is looking really good, minor nit around the error being returned when all parsing attempts fail.

util/certs/certs.go Outdated Show resolved Hide resolved
@detiber
Copy link
Member

detiber commented Jun 17, 2020

/lgtm
/assign @vincepri

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 17, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 22, 2020
@fabriziopandini
Copy link
Member

@maelk thanks!
/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 22, 2020
@fabriziopandini
Copy link
Member

WRT to api-diff failures, rif #3175 (comment)

@benmoss
Copy link

benmoss commented Jun 22, 2020

@detiber y'approve?

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

Couple of minor nits related to gomega matchers being used for the tests, otherwise I think this is ready to go.

@maelk thank you for tackling this and working through the implementation with us :)

util/certs/certs_test.go Outdated Show resolved Hide resolved
util/certs/certs_test.go Outdated Show resolved Hide resolved
@vincepri
Copy link
Member

/milestone v0.3.7

@k8s-ci-robot k8s-ci-robot added this to the v0.3.7 milestone Jun 22, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 22, 2020
@k8s-ci-robot
Copy link
Contributor

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

Test name Commit Details Rerun command
pull-cluster-api-apidiff 77c424e link /test pull-cluster-api-apidiff

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.

@benmoss
Copy link

benmoss commented Jun 22, 2020

/lgtm
🎉 :shipit:

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

benmoss commented Jun 22, 2020

/approve

1 similar comment
@detiber
Copy link
Member

detiber commented Jun 22, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benmoss, detiber

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 22, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8d137e6 into kubernetes-sigs:master Jun 22, 2020
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. 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.

Support PKCS8 private key for user CA private key
6 participants