Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#918 from Deydra71/ca-time
Browse files Browse the repository at this point in the history
[tls] Change CA time check to minutes instead of hours
  • Loading branch information
openshift-merge-bot[bot] authored Jul 10, 2024
2 parents da9a7be + b8ac4c5 commit 3ab35a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/openstack/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ func ensureCaBundles(
return ctrl.Result{}, err
}

if len(caCertStatusBundle.certs) == 0 {
return ctrl.Result{}, fmt.Errorf("caCertStatusBundle.certs is empty")
}

status := corev1.TLSCAStatus{
Name: caName,
Expires: caCertStatusBundle.certs[0].expire.Format(time.RFC3339),
Expand Down Expand Up @@ -710,8 +714,8 @@ func getOperatorCABundle(caFile string) ([]byte, error) {
return contents, nil
}

func days(t time.Time) int {
return int(math.Round(time.Since(t).Hours() / 24))
func minutes(t time.Time) int {
return int(math.Round(time.Since(t).Minutes()))
}

type caBundle struct {
Expand Down Expand Up @@ -765,7 +769,7 @@ func (cab *caBundle) getCertsFromPEM(PEMdata []byte) error {
}

// validate if the CA expired
if -days(certificate.NotAfter) <= 0 {
if -minutes(certificate.NotAfter) <= 0 {
continue
}

Expand Down

0 comments on commit 3ab35a8

Please sign in to comment.