From 3326a8b7e178b009d4dea16dc45b56232b9b565e Mon Sep 17 00:00:00 2001 From: Saurov Chandra Biswas <48715910+souravbiswassanto@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:01:04 +0600 Subject: [PATCH] TLS fix for Postgres (#1276) /cherry-pick Signed-off-by: souravbiswassanto Signed-off-by: Tamal Saha --- pkg/util.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/util.go b/pkg/util.go index 428b932ee..86b3e12df 100644 --- a/pkg/util.go +++ b/pkg/util.go @@ -114,8 +114,11 @@ func (opt *postgresOptions) setDatabaseCredentials(appBinding *appcatalog.AppBin } userName := "" - - if _, ok := appBindingSecret.Data[core.TLSPrivateKeyKey]; ok { + if appBinding.Spec.TLSSecret != nil && appBinding.Spec.TLSSecret.Name != "" { + appBindingSecret, err = opt.kubeClient.CoreV1().Secrets(appBinding.Namespace).Get(context.TODO(), appBinding.Spec.TLSSecret.Name, metav1.GetOptions{}) + if err != nil { + return err + } certByte, ok := appBindingSecret.Data[core.TLSCertKey] if !ok { return fmt.Errorf("can't find client cert")