Skip to content

Commit

Permalink
Add nil pointer check for client cert key pairs (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahreehong authored Jul 31, 2024
1 parent a407200 commit 6afd038
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (r *EtcdadmClusterReconciler) getClientCerts(ctx context.Context, cluster *
return tls.Certificate{}, err
}
if clientCertKey := clientCert.GetByPurpose(secret.APIServerEtcdClient); clientCertKey != nil {
if clientCertKey.KeyPair == nil {
return tls.Certificate{}, fmt.Errorf("client cert key pair not found for cluster")
}
return tls.X509KeyPair(clientCertKey.KeyPair.Cert, clientCertKey.KeyPair.Key)
}
return tls.Certificate{}, fmt.Errorf("nil returned from getting etcd CA certificate by purpose %s", secret.APIServerEtcdClient)
Expand Down

0 comments on commit 6afd038

Please sign in to comment.