mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-11 14:16:52 +10:00
@@ -37,14 +37,10 @@ func (h *Helper) DefaultValidationSet() []ValidationFunc {
|
||||
validations.ExpectValidAnnotations,
|
||||
validations.ExpectValidPrivateKeyData,
|
||||
validations.ExpectValidCertificate,
|
||||
//validations.ExpectCertificateOrganizationToMatch,
|
||||
validations.ExpectCertificateDNSNamesToMatch,
|
||||
validations.ExpectCertificateURIsToMatch,
|
||||
validations.ExpectValidCommonName,
|
||||
validations.ExpectValidNotAfterDate,
|
||||
validations.ExpectKeyUsageExtKeyUsageServerAuth,
|
||||
validations.ExpectKeyUsageExtKeyUsageClientAuth,
|
||||
validations.ExpectKeyUsageKeyUsageKeyAgreement,
|
||||
validations.ExpectEmailsToMatch,
|
||||
}
|
||||
}
|
||||
@@ -60,7 +56,6 @@ func (h *Helper) ValidationSetForUnsupportedFeatureSet(fs featureset.FeatureSet)
|
||||
validations.ExpectCertificateDNSNamesToMatch,
|
||||
validations.ExpectValidCommonName,
|
||||
validations.ExpectValidNotAfterDate,
|
||||
validations.ExpectKeyUsageKeyUsageKeyAgreement,
|
||||
}
|
||||
|
||||
if !fs.Contains(featureset.URISANsFeature) {
|
||||
|
||||
@@ -65,20 +65,22 @@ func ExpectValidPrivateKeyData(certificate *cmapi.Certificate, secret *corev1.Se
|
||||
}
|
||||
|
||||
// validate private key is of the correct type (rsa or ecdsa)
|
||||
switch certificate.Spec.PrivateKey.Algorithm {
|
||||
case cmapi.PrivateKeyAlgorithm(""),
|
||||
cmapi.RSAKeyAlgorithm:
|
||||
_, ok := key.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
return fmt.Errorf("Expected private key of type RSA, but it was: %T", key)
|
||||
if certificate.Spec.PrivateKey != nil {
|
||||
switch certificate.Spec.PrivateKey.Algorithm {
|
||||
case cmapi.PrivateKeyAlgorithm(""),
|
||||
cmapi.RSAKeyAlgorithm:
|
||||
_, ok := key.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
return fmt.Errorf("Expected private key of type RSA, but it was: %T", key)
|
||||
}
|
||||
case cmapi.ECDSAKeyAlgorithm:
|
||||
_, ok := key.(*ecdsa.PrivateKey)
|
||||
if !ok {
|
||||
return fmt.Errorf("Expected private key of type ECDSA, but it was: %T", key)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unrecognised requested private key algorithm %q", certificate.Spec.PrivateKey.Algorithm)
|
||||
}
|
||||
case cmapi.ECDSAKeyAlgorithm:
|
||||
_, ok := key.(*ecdsa.PrivateKey)
|
||||
if !ok {
|
||||
return fmt.Errorf("Expected private key of type ECDSA, but it was: %T", key)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unrecognised requested private key algorithm %q", certificate.Spec.PrivateKey.Algorithm)
|
||||
}
|
||||
|
||||
// TODO: validate private key KeySize
|
||||
|
||||
@@ -46,6 +46,7 @@ var _ = framework.ConformanceDescribe("Certificates", func() {
|
||||
featureset.CommonNameFeature,
|
||||
featureset.IPAddressFeature,
|
||||
featureset.URISANsFeature,
|
||||
featureset.OnlySAN,
|
||||
)
|
||||
|
||||
provisioner := new(venafiProvisioner)
|
||||
|
||||
Reference in New Issue
Block a user