Skip to content

Commit

Permalink
Merge pull request #417 from stuggi/admin_client_verify_cert
Browse files Browse the repository at this point in the history
[tls] Use CABundle in admin client to validate tls cert
  • Loading branch information
openshift-merge-bot[bot] committed May 22, 2024
2 parents 393e9ba + ff73de9 commit 46992c6
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions api/v1beta1/keystoneapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"sigs.k8s.io/controller-runtime/pkg/client"

openstack "github.com/openstack-k8s-operators/lib-common/modules/openstack"
Expand Down Expand Up @@ -111,9 +112,24 @@ func GetScopedAdminServiceClient(

tlsConfig := &openstack.TLSConfig{}
if parsedAuthURL.Scheme == "https" {
// TODO: (mschuppert) for now just set to insecure, when keystone got
// enabled for internal tls, get the CA secret name from the keystoneAPI
tlsConfig.Insecure = true
caCert, ctrlResult, err := secret.GetDataFromSecret(
ctx,
h,
keystoneAPI.Spec.TLS.CaBundleSecretName,
10*time.Second,
tls.InternalCABundleKey)
if err != nil {
return nil, ctrl.Result{}, err
}
if (ctrlResult != ctrl.Result{}) {
return nil, ctrl.Result{}, fmt.Errorf("the CABundleSecret %s not found", keystoneAPI.Spec.TLS.CaBundleSecretName)
}

tlsConfig = &openstack.TLSConfig{
CACerts: []string{
caCert,
},
}
}

// get the password of the admin user from Spec.Secret
Expand All @@ -128,7 +144,7 @@ func GetScopedAdminServiceClient(
return nil, ctrl.Result{}, err
}
if (ctrlResult != ctrl.Result{}) {
return nil, ctrlResult, nil
return nil, ctrlResult, fmt.Errorf("password for user %s not found", keystoneAPI.Spec.PasswordSelectors.Admin)
}

os, err := openstack.NewOpenStack(
Expand Down

0 comments on commit 46992c6

Please sign in to comment.