Repository navigation
CertificateSigningRequest selfsigned controller - #4100
jetstack-bot merged 3 commits into
Conversation
Signed-off-by: joshvanl <[email protected]>
Signed-off-by: joshvanl <[email protected]>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoshVanL The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
SgtCoDFish
left a comment
There was a problem hiding this comment.
(Sorry this is long, it's a fiddly thing to discuss 😅 )
When I looked into the SelfSigned issuer for CSR resources, the block I highlighted with a ⭐ is the bit that made me really stop and think.
For CertificateRequests - which are created because of a Certificate resource - the Certificate will cause a secret with a private key to be created.
That's the thing which makes SelfSigned CertificateRequests worth using, really. For CSR resources today, without the secret being generated by cert-manager, the workflow is really hostile and circuitous:
- Create a private key locally, using
opensslor something else - Upload the private key into Kubernetes as a
Secret(this is a pain withkubectl) - Create a CSR locally, using
opensslor something else - Upload the CSR into Kubernetes as a
CertificateSigningRequest - The CSR is processed by cert-manager and a cert is issued.
Crucially, because the cert is self-signed, step 3 is entirely pointless. The user already has the private key and the details of the cert they want to issue. They can just issue the cert rather than faffing around with CSRs.
I detailed this in #3646 where @munnerz pointed out that the goal was for CertificateSigningRequest to eventually entirely replace CertificateRequest. If that's the case, we absolutely do need to support SelfSigned issuers with CSR resources at some point, because somewhere down the line we'll do "the switch" and Certificate resources will (have the option to) create CertificateSigningRequests instead of CertificateRequests.
That leads me to my main point:
Summary: Until (and unless) we do "the switch" I think the SelfSigned issuer type for CSRs provides no value to users. More pertinently: before "the switch", I think everyone who even thinks about using a SelfSigned issuer with a CSR resource is almost certainly making a mistake and what they actually want is a CA issuer.
Adding support for SelfSigned - like any new code - increases the amount of code we have to maintain and test, and could risk us locking in design choices now which will be harder to change in the future.
Given all that, is it maybe worth considering shelving adding support for SelfSigned until we're ready to make "the switch"?
| // Sign attempts to sign the given CertificateSigningRequest based on the | ||
| // provided SelfSigned Issuer or ClusterIssuer. This function will update the | ||
| // resource if signing was successful. Returns an error which, if not nil, | ||
| // should trigger a retry. | ||
| // CertificateSigningRequests must have the | ||
| // "experimental.cert-manager.io/private-key-secret-name" annotation present to | ||
| // be signed. This annotation must reference a valid Secret containing a CA | ||
| // private key for signing. |
There was a problem hiding this comment.
nitpick: I like this comment and it's a big improvement to have it versus the lack of one for the CR selfsigned controller.
Just a minor nitpick that "CA private key" could be confusing for people, since there isn't really such a concept.
| // Sign attempts to sign the given CertificateSigningRequest based on the | |
| // provided SelfSigned Issuer or ClusterIssuer. This function will update the | |
| // resource if signing was successful. Returns an error which, if not nil, | |
| // should trigger a retry. | |
| // CertificateSigningRequests must have the | |
| // "experimental.cert-manager.io/private-key-secret-name" annotation present to | |
| // be signed. This annotation must reference a valid Secret containing a CA | |
| // private key for signing. | |
| // Sign attempts to sign the given CertificateSigningRequest based on the | |
| // provided SelfSigned Issuer or ClusterIssuer. This function will update the | |
| // resource if signing was successful. Returns an error which, if not nil, | |
| // should trigger a retry. | |
| // CertificateSigningRequests must have the | |
| // "experimental.cert-manager.io/private-key-secret-name" annotation present to | |
| // be signed. This annotation must reference a valid Secret containing a | |
| // private key for signing. |
| } | ||
|
|
||
| if cmerrors.IsInvalidData(err) { | ||
| message := fmt.Sprintf("Failed to parse signing CA key from secret %s/%s", resourceNamespace, secretName) |
There was a problem hiding this comment.
suggestion/nitpick: I think "signing CA key" has the potential to be confusing for people because it makes the SelfSigned issuer sound like the CA issuer. I guess it does end up being the "signing CA key" in a way, but I think just plain "private key" is clearer.
| message := fmt.Sprintf("Failed to parse signing CA key from secret %s/%s", resourceNamespace, secretName) | |
| message := fmt.Sprintf("Failed to parse private key from secret %s/%s", resourceNamespace, secretName) |
| privatekey, err := kube.SecretTLSKey(ctx, s.secretsLister, resourceNamespace, secretName) | ||
| if apierrors.IsNotFound(err) { | ||
| message := fmt.Sprintf("Referenced Secret %s/%s not found", resourceNamespace, secretName) | ||
| log.Error(err, message) | ||
| s.recorder.Event(csr, corev1.EventTypeWarning, "SecretNotFound", message) | ||
| util.CertificateSigningRequestSetFailed(csr, "SecretNotFound", message) | ||
| _, err = s.certClient.UpdateStatus(ctx, csr, metav1.UpdateOptions{}) | ||
| return err | ||
| } |
There was a problem hiding this comment.
Marking this block with a ⭐ to refer to it in the review overall.
Signed-off-by: joshvanl <[email protected]>
|
I have updated the strings containing "CA private key".
Whilst I understand the sentiment, we should still add support for this Issuer since having full coverage of all Issuer types is the target. I disagree that adding this code is more arduous since it has units tests and is well contained. This PR moves to a conformance e2e testing strategy similar to Certificates which makes testing different issuers easy to add. I also don't think we should be too concerned with locking in the design since it follows the same design as CR's. I'd rather merge this sooner rather than merging it later. |
|
/lgtm |
This PR adds the SelfSigned CertificateSigningRequest controller for signing requests referencing a self-signed Issuer or ClusterIssuer.
Like the CertificateRequest controller, this requires an annotation which is used to reference the Secret containing the private key that signed the requester's CSR.
This PR contains no E2E tests. I have created a conformance suite for CertificateSigningRequest controllers which includes both the CA and SelfSigned issuers. This will be in a follow-up PR in to help reviewing.
/assign @jakexks @irbekrm @maelvls @SgtCoDFish
/milestone Next
/kind feature