Documentation
¶
Index ¶
- Constants
- func CreatePrivateKey(keyConfig KeyConfig) (crypto.Signer, *pem.Block, x509.SignatureAlgorithm, error)
- func EnsureCertificate[T interface{ ... }](ctx context.Context, owner T, subject string, ...) (op.Result, *corev1.Secret, error)
- func GenerateCertificate[T interface{ ... }](ctx context.Context, owner T, subject string, ca types.NamespacedName, ...) (op.Result, *corev1.Secret, error)
- func GetManagedLabelForServiceSecret(svcNN types.NamespacedName) client.MatchingLabels
- func IsTLSSecretValid(secret *corev1.Secret) bool
- func ParsePrivateKey(pemBlock *pem.Block) (crypto.Signer, x509.SignatureAlgorithm, error)
- func SetCALogger(logger logr.Logger)
- func SignatureAlgorithmForKeyType(keyType x509.PublicKeyAlgorithm) x509.SignatureAlgorithm
- type KeyConfig
Constants ¶
const ( // SignatureAlgorithmForECDSA is the default signature algorithm for ECDSA keys. SignatureAlgorithmForECDSA x509.SignatureAlgorithm = x509.ECDSAWithSHA256 // SignatureAlgorithmForRSA is the default signature algorithm for RSA keys. SignatureAlgorithmForRSA x509.SignatureAlgorithm = x509.SHA256WithRSA )
Variables ¶
This section is empty.
Functions ¶
func CreatePrivateKey ¶
func CreatePrivateKey( keyConfig KeyConfig, ) (crypto.Signer, *pem.Block, x509.SignatureAlgorithm, error)
CreatePrivateKey generates a private key based on the provided keyConfig.
func EnsureCertificate ¶
func EnsureCertificate[
T interface {
k8sresources.ControlPlaneOrDataPlaneOrKonnectExtension
client.Object
},
](
ctx context.Context,
owner T,
subject string,
mtlsCASecretNN types.NamespacedName,
usages []certificatesv1.KeyUsage,
cl client.Client,
additionalMatchingLabels client.MatchingLabels,
certTTL time.Duration,
) (op.Result, *corev1.Secret, error)
EnsureCertificate creates a Secret for subject, signed by the CA in mtlsCASecretNN. It reuses the owner's single matching Secret, re-issuing the leaf into that Secret when the stored CA bundle no longer matches. It re-creates the Secret when the stored certificate is unusable or is for another subject. It returns the operation it performed and an error indicating any failures it encountered.
func GenerateCertificate ¶ added in v2.2.7
func GenerateCertificate[T interface {
k8sresources.ControlPlaneOrDataPlaneOrKonnectExtension
client.Object
}](
ctx context.Context,
owner T,
subject string,
ca types.NamespacedName,
usages []certificatesv1.KeyUsage,
cl client.Client,
labels client.MatchingLabels,
certTTL time.Duration,
opts ...k8sresources.SecretOpt,
) (op.Result, *corev1.Secret, error)
GenerateCertificate creates a new certificate Secret without reducing existing generations. Callers must retain and retire those generations safely.
func GetManagedLabelForServiceSecret ¶
func GetManagedLabelForServiceSecret(svcNN types.NamespacedName) client.MatchingLabels
GetManagedLabelForServiceSecret returns a label selector for the ServiceSecret.
func IsTLSSecretValid ¶
IsTLSSecretValid checks if a Secret contains a valid TLS certificate and key.
func ParsePrivateKey ¶
ParsePrivateKey parses a PEM block and returns a crypto.Signer and x509.SignatureAlgorithm.
func SetCALogger ¶
SetCALogger sets the logger for the CFSSL signer. Call it once at the start of the program to ensure that CFSSL logs are captured by the operator's logger. Subsequent calls to this function will have no effect.
func SignatureAlgorithmForKeyType ¶
func SignatureAlgorithmForKeyType(keyType x509.PublicKeyAlgorithm) x509.SignatureAlgorithm
SignatureAlgorithmForKeyType returns the default signature algorithm for the provided key type.
Types ¶
type KeyConfig ¶
type KeyConfig struct {
// Type is the type of the key to generate
Type x509.PublicKeyAlgorithm
// Size is the size of the key to generate in bits.
// This is only used for RSA keys.
Size int
}
KeyConfig is the configuration for generating a private key.
func DetectCertType ¶ added in v2.1.1
DetectCertType inspects a PEM-encoded certificate and returns its KeyConfig. It uses the first block only: a CA Secret may carry its full chain in tls.crt, and that first certificate is the one that signs the issued certificates.