Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@matthewpi
Copy link
Contributor

Adds the ability to specify the key algorithm (csi.cert-manager.io/key-algorithm) and size (csi.cert-manager.io/key-size).

Algorithms:

  • RSA (2048 <-> 8192)
    • csi.cert-manager.io/key-algorithm: "RSA"
    • csi.cert-manager.io/key-size: "2048" (default if unset)
    • csi.cert-manager.io/key-encoding: "PKCS1" (default if unset)
  • ECDSA (256, 384, 521)
    • csi.cert-manager.io/key-algorithm: "ECDSA"
    • csi.cert-manager.io/key-size: "256" (default if unset)
    • csi.cert-manager.io/key-encoding: "PKCS8" (default if unset)
  • Ed25519
    • csi.cert-manager.io/key-algorithm: "Ed25519"
    • csi.cert-manager.io/key-size: "" (default if unset. Users MAY NOT set a size as Ed25519 doesn't have a configurable size)
    • csi.cert-manager.io/key-encoding: "PKCS8" (default if unset)

Closes #371

@cert-manager-prow cert-manager-prow bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label May 1, 2025
@cert-manager-prow
Copy link
Contributor

Hi @matthewpi. 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 /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-sigs/prow repository.

@cert-manager-prow cert-manager-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 1, 2025
@reyvonger
Copy link

bump

@reyvonger
Copy link

@munnerz @jakexks @wallrj-cyberark

help

@KLuuKer
Copy link

KLuuKer commented Jul 17, 2025

@wallrj

@reyvonger i think you tagged the wrong account for him

@SgtCoDFish
Copy link
Member

/ok-to-test

@cert-manager-prow cert-manager-prow bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 17, 2025
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

Hey, thanks for raising this, it looks really good! I think mostly this is good to go, I've just got a few comments about the UX of it from when I tested locally.

What do you think?

Comment on lines 127 to 129
if encoding != string(cmapi.PKCS1) && encoding != string(cmapi.PKCS8) {
return field.ErrorList{field.NotSupported(encodingPath, encoding, []string{string(cmapi.PKCS1), string(cmapi.PKCS8)})}
}
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Because this check is before the check on "alg" below, the error I get if I use a "wrong" key algorithm is really confusing.

I tested with this pod:

apiVersion: v1
kind: Pod
metadata:
  name: my-csi-app
  namespace: sandbox
  labels:
    app: my-csi-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/tls"
        name: tls
      command: [ "sleep", "1000000" ]
  volumes:
    - name: tls
      csi:
        driver: csi.cert-manager.io
        readOnly: true
        volumeAttributes:
          csi.cert-manager.io/issuer-name: intermediate-ca-issuer-2
          csi.cert-manager.io/issuer-kind: Issuer
          csi.cert-manager.io/dns-names: ${POD_NAME}.${POD_NAMESPACE}.svc.cluster.local
          csi.cert-manager.io/key-algorithm: ecdsa

and I got:

  Warning  FailedMount  2s (x4 over 5s)  kubelet            MountVolume.SetUp failed for volume "tls" : rpc error: code = Unknown desc = generating private key: volumeAttributes.csi.cert-manager.io/key-encoding: Unsupported value: "": supported values: "PKCS1", "PKCS8"

The error is actually the invalid key algorithm - if I use "ECDSA" the encoding is defaulted for me.

What do you think to moving this encoding check below the check on alg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll move the encoding check below the alg check.

return field.ErrorList{field.NotSupported(encodingPath, encoding, []string{string(cmapi.PKCS1), string(cmapi.PKCS8)})}
}

switch alg {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Sort of related to my other comment - I think checking for exactly the cmapi.*KeyAlgorithm string is a bit strict and the UX isn't great. If I write csi.cert-manager.io/key-algorithm: ecdsa I kinda want that to work - it's not ambiguous, it's just the wrong casing.

Can we using strings.ToUpper on alg when making these comparisons, so that users don't have to remember the correct case to use when writing YAML?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I also do something similar for encoding as well? So pkcs1 and pkcs8 are also supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of converting the case or doing case-insensitive comparisons everywhere, I normalize the user-provided values when we set the defaults so we can use the constants everywhere in the code-base.

Copy link
Member

Choose a reason for hiding this comment

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

I really like your approach, yeah. Much better, thanks 😁

@matthewpi matthewpi force-pushed the additional-key-algorithms branch from 375bf96 to 7e5f27f Compare July 17, 2025 17:16
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thanks so much for this, it's fantastic. I'll set a reminder for myself to revisit this next week and hopefully get a release made including this feature!

Cheers 🚀

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2025
@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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

@cert-manager-prow cert-manager-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 18, 2025
@cert-manager-prow cert-manager-prow bot merged commit d906827 into cert-manager:main Jul 18, 2025
5 checks passed
@SgtCoDFish
Copy link
Member

Hey, quick update on the release: I think I'm going to hold off until next week. There's an issue unrelated to this PR which we've discovered in csi-lib (a dependency of csi-driver) and if we make a change to csi-lib I'd like it to be included in csi-driver. I'm off work until next Monday, so I'll revisit then. Sorry for the delay!

@SgtCoDFish
Copy link
Member

Another update: sorry again about the delay. I was waiting for investigation on the other bug I mentioned, but I don't think it'll happen really soon. I'll try and release on Monday 👍

@SgtCoDFish
Copy link
Member

This was released in the latest csi-driver release! Thank you for your work on this

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 that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. ok-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.

Specify private key algorithm/size

4 participants