CNTRLPLANE-2903: Add configurable PKI profile support#2127
CNTRLPLANE-2903: Add configurable PKI profile support#2127sanchezl wants to merge 4 commits intoopenshift:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sanchezl The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
9aba308 to
d3568d4
Compare
0632ccd to
baa0195
Compare
|
@sanchezl: This pull request references CNTRLPLANE-2903 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@sanchezl: This pull request references CNTRLPLANE-2903 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
| func DefaultPKIProfile() configv1alpha1.PKIProfile { | ||
| return configv1alpha1.PKIProfile{ | ||
| Defaults: configv1alpha1.DefaultCertificateConfig{ | ||
| Key: configv1alpha1.KeyConfig{ | ||
| Algorithm: configv1alpha1.KeyAlgorithmRSA, | ||
| RSA: configv1alpha1.RSAKeyConfig{KeySize: 2048}, | ||
| }, | ||
| }, | ||
| SignerCertificates: configv1alpha1.CertificateConfig{ | ||
| Key: configv1alpha1.KeyConfig{ | ||
| Algorithm: configv1alpha1.KeyAlgorithmRSA, | ||
| RSA: configv1alpha1.RSAKeyConfig{KeySize: 4096}, | ||
| }, | ||
| }, | ||
| } | ||
| } |
There was a problem hiding this comment.
Since this wasn't in the enhancement, can we make these defaults more apparent/explicit? I'll have to align the installer to use these defaults as well.
So rather than defining it in two places, maybe the default key sizes and algo for signer/leaf certs can live in the API as a const as the source of truth and I can consume it from there (until I can get the installer to switch over to library-go's crypto pkg).
E.g:
https://github.com/openshift/api/blob/0608f61fdd6bd966ba0ded180a6f49005e30ae2f/config/v1alpha1/types_pki.go#L248-L256
There was a problem hiding this comment.
For unblocking the installer now: since this PR is still in review, feel free to duplicate the default values directly in the installer for now.
Introduce utilities for creating signing, server, client, and peer certificates. Include support for configurable key algorithms, customizable subjects, lifetimes, and extensions. Add comprehensive unit tests to validate all functionality.
Introduce PKI profile utilities to manage certificate configurations, including resolution, key strength comparisons, and API conversions. Add comprehensive unit tests to validate all functionality.
|
@sanchezl: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
@sanchezl: This pull request references CNTRLPLANE-2903 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
Overview
Adds configurable PKI profile support for enhancement #1882, using the API from openshift/api#2645.
PROOF: cluster-kube-apiserver-operator#2051 demonstrates the integration of these APIs into CKAO's cert rotation controllers.
pkg/crypto— Parameterized key generation and certificate creationKeyConfigtype supporting RSA (2048–8192 bit) and ECDSA (P-256/P-384/P-521)GenerateKeyPair(KeyConfig)andSubjectKeyIDFromPublicKey()for algorithm-agnostic key generationSubjectKeyIDFromPublicKey()uses truncated SHA-256 (first 160 bits per RFC 7093), consistent with Go 1.25+ (go.dev/issue/71746) and Let's Encrypt — FIPS-compatible, unlike the SHA-1 used by the legacy functionsNewSigningCertificate(name, keyConfig, ...opts)— self-signed root CA or intermediate CA viaWithSignerCA.NewServerCertificate(hostnames, keyConfig, ...opts)CA.NewClientCertificate(userInfo, keyConfig, ...opts)CA.NewPeerCertificate(hostnames, userInfo, keyConfig, ...opts)— both ServerAuth + ClientAuth EKUWithLifetime,WithSubject,WithSigner,WithExtensionsDigitalSignatureonly (noKeyEncipherment); signature algorithm auto-detected from signing keypkg/pki— Profile resolutionCertificateTypeenum: signer, serving, client, peerDefaultPKIProfile()— RSA-2048 default, RSA-4096 for signersPKIProfileProviderinterface withStaticPKIProfileProvider(installer/tests) andListerPKIProfileProvider(controllers)ResolveCertificateConfig(provider, certType, name)→CertificateConfig{Key}— resolves effective key config from profile with category overridespkg/operator/certrotation— Optional KeyConfig wiringKeyConfig *crypto.KeyConfigfield toRotatedSigningCASecret,ClientRotation,ServingRotation,SignerRotationKeyConfigis set, the newcrypto.New*Certificatefunctions are used; whennil, existing behavior is preservedDesign
pkg/cryptohas zero dependency onpkg/pkiorconfigv1alpha1ConfigurablePKI) checking is the caller's responsibility