-
Notifications
You must be signed in to change notification settings - Fork 68
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 pkcs12 password feature #229
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Hi @arsenalzp. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arsenalzp This looks like a good start! I have added some comments after my first review pass. Some of them are just suggestions - so feel free to disagree. But please explain why. 😉
/ok-to-test
Hello, |
// encodeJKS creates a binary JKS file from the given PEM-encoded trust bundle and password. | ||
// Note that the password is not treated securely; JKS files generally seem to expect a password | ||
// to exist and so we have the option for one. | ||
func (e jksEncoder) encode(trustBundle string) ([]byte, error) { | ||
cas, err := util.DecodeX509CertificateChainBytes([]byte(trustBundle)) | ||
func (e jksEncoder) encode() ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these function signatures being changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
Thank you for a review.
jksEncoder and pkcs12Encoder structures bring all necessary information in corresponding properties:
type encoderData struct {
storePasswd string
bundleData string
}
type pkcs12Encoder struct {
encoderData
}
type jksEncoder struct {
encoderData
}
In the future it might be reasonable to rewrite functions like populateAdditionalFormatData to either accept encoder interface and based on the casting result invoke corresponding encode()
method or use generics, something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think you need to change the signature of this function. That makes a struct instance locked to the bundle data. Why do you need to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it makes code more clear and avoid of copying bundle data between function/method.
The bundle data is tightly coupled to its encoder; imagine you would like to add decode(), transform() methods in the future, then it leads that the bundle data should be returned from one encoder method and immediately consumed by another one.
Let's look at how is the bundle data was being used before: put to populate function just only to be put to corresponding encoder's method again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty common in decorators. When will you use function parameters with your view on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, but at this moment encoder structure consists of 2 fields: password one and data one, what if we need more parameters for encoder, more methods. Ephemeral example - push bundle data into some destination, then encode, so that data should be put as argument twice: to some push(data)
as well as to encode(data)
functions.
My proposal looks pretty good, we operate by encoder structure, it might be pushed anywhere, with all necessary parameters. populateAdditionalFormatData
function accept encoder structure, then within that function we can work the structure we want by any way, everything what we need is already inside that structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear colleagues, if you insist to use bundle data as argument to encode
method, I will rewrite, of course.
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add test for PKCS12 with arbitrary password Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add PKCS12 arbitrary password tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> remove unnecessary labels from ConfigMap resource Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix some remarks from the PR Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix JKS tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> reflect PKCS12 and JKS encoders modification to integration test Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix typo in the Values part Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm values and doc files Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
@@ -31,6 +31,7 @@ Kubernetes: `>= 1.25.0-0` | |||
| app.metrics.service.enabled | bool | `true` | Create a Service resource to expose metrics endpoint. | | |||
| app.metrics.service.servicemonitor | object | `{"enabled":false,"interval":"10s","labels":{},"prometheusInstance":"default","scrapeTimeout":"5s"}` | ServiceMonitor resource for this Service. | | |||
| app.metrics.service.type | string | `"ClusterIP"` | Service type to expose metrics. | | |||
| app.pkcs12Password | string | `nil` | Password for JKS and PKCS12 stores protection | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these docs are a bit misleading. The default should be ""
(empty string) creating a password-less PKC12 truststore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this line of code will be changed
// encodeJKS creates a binary JKS file from the given PEM-encoded trust bundle and password. | ||
// Note that the password is not treated securely; JKS files generally seem to expect a password | ||
// to exist and so we have the option for one. | ||
func (e jksEncoder) encode(trustBundle string) ([]byte, error) { | ||
cas, err := util.DecodeX509CertificateChainBytes([]byte(trustBundle)) | ||
func (e jksEncoder) encode() ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think you need to change the signature of this function. That makes a struct instance locked to the bundle data. Why do you need to change it?
I guess it makes code more clear and avoid of copying bundle data between function/method. |
Hello colleagues, |
Fields or function params is not a blocker for me. I prefer function params, but. Maybe you can fix (and close) the other open discussions? So we are left with just that point to land? |
This is a drive-by comment and I don't have time to fully review but I think I'm negative on adding this as a command-line flag. This maps neatly to being added in the resource, which is where I'd expect to be able to set it: {
"apiVersion": "trust.cert-manager.io/v1alpha1",
"kind": "Bundle",
"metadata": {
"name": "testing"
},
"spec": {
"sources": [
{
"useDefaultCAs": true
}
],
"target": {
"additionalFormats": {
"jks": {
"key": "my-bundle.jks",
"password": "super_secret",
}
},
"configMap": {
"key": "mybundle.pem"
}
}
}
} Putting myself in the shoes of a user, I'd be familar with the concept that each JKS file can have a different password. I'd expect trust-manager to work the same way as that. Obviously today we have one global setting for the password, but that's just because the JKS files need some password, not because the setting should be global to all bundles. I can't really see a reason for this to be a CLI flag. |
Hello, |
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add test for PKCS12 with arbitrary password Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add PKCS12 arbitrary password tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> remove unnecessary labels from ConfigMap resource Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix some remarks from the PR Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix JKS tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> reflect PKCS12 and JKS encoders modification to integration test Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix typo in the Values part Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm values and doc files Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> Add pkcs12 password feature in the Bundle resource Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix password issue in helm chart Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
Another PR #233 related to @SgtCoDFish was submitted. |
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add test for PKCS12 with arbitrary password Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> add PKCS12 arbitrary password tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> remove unnecessary labels from ConfigMap resource Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix some remarks from the PR Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix JKS tests Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> reflect PKCS12 and JKS encoders modification to integration test Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> fix typo in the Values part Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm docs Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> update Helm values and doc files Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com> tweak readme to encourage use Signed-off-by: Ashley Davis <ashley.davis@venafi.com> chore: generate applyconfigurations for custom resources Signed-off-by: Erik Godding Boye <egboye@gmail.com> Bump the all group with 3 updates Bumps the all group with 3 updates: [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo), [github.com/onsi/gomega](https://github.com/onsi/gomega) and [sigs.k8s.io/structured-merge-diff/v4](https://github.com/kubernetes-sigs/structured-merge-diff). Updates `github.com/onsi/ginkgo/v2` from 2.13.0 to 2.13.1 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.13.0...v2.13.1) Updates `github.com/onsi/gomega` from 1.29.0 to 1.30.0 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](onsi/gomega@v1.29.0...v1.30.0) Updates `sigs.k8s.io/structured-merge-diff/v4` from 4.2.3 to 4.4.1 - [Release notes](https://github.com/kubernetes-sigs/structured-merge-diff/releases) - [Changelog](https://github.com/kubernetes-sigs/structured-merge-diff/blob/master/RELEASE.md) - [Commits](kubernetes-sigs/structured-merge-diff@v4.2.3...v4.4.1) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: sigs.k8s.io/structured-merge-diff/v4 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] <support@github.com> chore!: remove .status.target field from Bundle API Signed-off-by: Erik Godding Boye <egboye@gmail.com>
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits. 📝 Please follow instructions in the contributing guide to update your commits with the DCO Full details of the Developer Certificate of Origin can be found at developercertificate.org. The list of commits missing DCO signoff:
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. |
@arsenalzp: The following tests failed, say
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. |
This PR is related to the issue #199
It add PKCS12 arbitrary password feature which allows to set a password for PKCS12 bundle as well as don't remove password-less PKCS12 feature.